简体   繁体   中英

Can I use Cordova to access the Library dir within my iPhone app's sandbox?

My iPhone application's sandbox includes 3 directories: Documents, Library and tmp.

I can access the Documents directory if I use this Cordova code snippet:

window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onSuccess, onError);   

I can access the tmp directory if I use this Cordova code snippet:

window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, onSuccess, onError);  

Is there a way to access the Library directory using Cordova?

It looks like Cordova does not provide an API to access the Library directory. Note the Apple documentation for the Library directory: “This directory is the top-level directory for files that are not user data files. You typically put files in one of several standard subdirectories but you can also create custom subdirectories for files you want backed up but not exposed to the user. You should not use this directory for user data files. The contents of this directory (with the exception of the Caches subdirectory) are backed up by iTunes.” If you still need Javascript access to the Library directory you may consider writing a custom Cordova plugin. Be aware about following Apple guidelines, otherwise they might reject your application when submitted for review.

Try using resolveLocalFileSystemURL, I tried with Cordova 3. Remember to follow the latest Apple's guidelines on using different storage locations https://developer.apple.com/icloud/documentation/data-storage/index.html or otherwise your app will be rejected for AppStore release.

resolveLocalFileSystemURL(cordova.file.dataDirectory,//data directory points to Library/NoCloud
win-callback(directory){
}
fail-callback(error){
});

For other directories, replace 'cordova.file.dataDirectory' with;

cordova.file.applicationDirectory
cordova.file.applicationStorageDirectory 
cordova.file.documentsDirectory
cordova.file.syncedDataDirectory
cordova.file.cacheDirectory
cordova.file.tempDirectory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM