Hassan ALi
Hassan ALi

Reputation: 1331

UIFileSharingEnabled has no effect in my cordova app for ios

I've added UIFileSharingEnabled to the .plist. Per suggestions, I have:

  1. removed the app and redeployed it several times
  2. attempted to disconnect after redeploying I have not been able to get the app visible in the File Sharing section in iTunes. I have added the plugin cordova-plugin-itunesfilesharing

Which added UIFileSharingEnabled to the .plist But it has no effect to application .

Edit:

I am trying to use cordova-plugin-itunesfilesharing I added these <key>UIFileSharingEnabled</key> <true/> in my .plist file. I need to turn on itunes file sharing in my ios application.

Upvotes: 1

Views: 1176

Answers (1)

Shlomo Georg Konwisser
Shlomo Georg Konwisser

Reputation: 443

In addition to using cordova-plugin-itunesfilesharing, you also need to put your files in the app's Documents directory to make them visible via iTunes. I'm assuming you're using cordova-plugin-file for the actual file writing. In this case, cordova.file.documentsDirectory will point to the Documents folder on iOS.

Example:

var isAppend = true;
window.resolveLocalFileSystemURL(cordova.file.documentsDirectory, function (dir) {
  dir.getFile("my_file_name.txt", {create: true}, function (fileEntry) {
    fileEntry.createWriter(function (fileWriter) {

            fileWriter.onerror = function (e) {
                console.log("Failed writing to file: " + e.message);
            };

            // If we are appending data to file, go to the end of the file.
            if (isAppend) {
                try {
                    console.log("isAppend = TRUE, seeking log file end");
                    fileWriter.seek(fileWriter.length);
                }
                catch (e) {
                    console.log("Failed seeking end of file: " + e.message);
                }
            }
            fileWriter.write(contentToBeWritten);
        }
    );
  });
});

Upvotes: 1

Related Questions