I believe this is called a "Share Extension", and unfortunately at the moment from some quick searching, I don't think this has been plugin-ized in cordova yet. I'm guessing it involves configurations that simply aren't supported by the plugin infrastructure yet (but not positive).
If that's true then your solution would be to use PhoneGap locally on OSX and utilize XCode for a Share Extension.
Edit: might be possible, see reply below.
Cancel that, this might be possible. Have a look at this post: cordova - Share something to a phonegap app - Stack Overflow (down below you'll see "Edit : there are a few people asking how to do this on iOS").
- Associate your app with the right file type associations by adding the relevant information in your info.plist. This SO answer explains how to do it : How do I associate file types with an iPhone application?. This will make your app appear in the list but your app won't receive the data yet.
- Your application will now be launched with new parameters. You now have to be able to read these parameters. Check this question/answer on SO, it does exactly that : How to pass arguments to app built on Phonegap
For the first part you'd need to modify your app's plist -- on Build this is done with config-file elements: Modifying Manifests | PhoneGap Docs
For the second part, you might need to use a custom url scheme plugin to handle the launch arguments: GitHub - EddyVerbruggen/Custom-URL-scheme: Launch your Cordova/PhoneGap app by a Custom URL scheme like mycoolapp://
You'll need to do some experimentation here, not sure about all the details.
First of all, thank you for your detailed answer. Now I know where to start and that it is possible.
I tried associating jpeg files with my application. For some reason, my app still isn't displayed in the share menu. (Tested in the Photos application and a .jpg image in Safari)
Am I missing something? This is what I added to my config.xml:
<gap:config-file platform="ios" parent="CFBundleDocumentTypes" mode="replace"> <array> <dict> <key>CFBundleTypeName</key> <string>JPG</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.jpeg</string> </array> </dict> </array> </gap:config-file>
I also tried replacing the CFBundleTypeName "JPG" with "public.jpeg" but that didn't work either.
I unpacked the .ipa file and converted the plist file to .xml. Here, I can see my entries listed as expected:
<key>CFBundleDisplayName</key> <string>Test-App</string> <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>public.jpeg</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.jpeg</string> </array> </dict> </array> <key>CFBundleExecutable</key> <string>TestApp</string>
According to System-Declared Uniform Type Identifiers , public.jpeg should be the correct content type. Core Foundation Keys tells me that it is required to use LSItemContentTypes (or similar) which I am using. So what could be the reason that my application is still not listed in the share dialog? Is it a problem with PGB or did I miss a key that is required?
What I didn't add was the file icon (in the example from SO: Document-molecules-320.png and Document-molecules-64.png). I am not sure where to put these files (somewhere in the locales folder mabye?). But this souldn't be the reason my application isn't listed in the share dialog since I am not creating a new file type.