Home > Net >  Cordova downloaded html file not accessible with VKwebview iOS
Cordova downloaded html file not accessible with VKwebview iOS

Time:11-19

Using the contentsync plugin, I am downloading html from my server. The files are downloaded and I get the save path etc.

When trying to load the html into a div using jquery, VKwebview does not allow the loading of file://path_to_resource. There is no error, the view is just blank.

On an android device, the code works so I am fairly certain that it is the VKwebview

function startSync() {

var sync = ContentSync.sync({ src: imageZip, id: 'kittenZip' });

sync.on('progress', function(data) {
    imageDiv.innerHTML = "<p>Syncing images: " data.progress   "%</p>";
});

sync.on('complete', function(data) {
    console.log(data.localPath);
    $('#html_div').load("file://"   data.localPath   "/index.html") 
}
    
});

sync.on('error', function(e) {
    console.log('Error: ', e.message);
    // e.message
});

sync.on('cancel', function() {
    // triggered if event is cancelled
}); 

}

CodePudding user response:

You can install cordova-plugin-ios-xhr and set your preferences to

 <preference name="allowFileAccessFromFileURLs" value="true" />
 <preference name="allowUniversalAccessFromFileURLs" value="true" />

This should solve the file:// issue

  • Related