cordova-plugin-openwith icon indicating copy to clipboard operation
cordova-plugin-openwith copied to clipboard

Is Image Sharing Required by this plugin? Can't get it work sharing text only....

Open viking2917 opened this issue 6 years ago • 15 comments

Great plugin! Thank you so much for putting it together!

Question: I have an app that I would like to receive shares of text from other apps, but can't accept image sharing. Is that possible? When I try what looks like the obvious, it doesn't seem to work...e.g.:

If I install the plugin via:

cordova plugin add cc.fovea.cordova.openwith --variable ANDROID_MIME_TYPE="image/*" --variable IOS_URL_SCHEME=ccfoveaopenwithdemo --variable IOS_UNIFORM_TYPE_IDENTIFIER=public.image

it works as expected - the photos app can share images to my app. But text selected in an app cannot.

However, if I install via:

cordova plugin add cc.fovea.cordova.openwith --variable ANDROID_MIME_TYPE="text/*" --variable IOS_URL_SCHEME=ccfoveaopenwithdemo --variable IOS_UNIFORM_TYPE_IDENTIFIER=public.text

Then neither sharing an image nor text to my app seems possible (my app doesn't show in the share menu).

Is it possible to only share text? I have not yet tried the "extra actions" approach but would prefer not to have my app show on the image sharing menu since I can't accept it...

Thanks!

viking2917 avatar Mar 16 '18 23:03 viking2917

Hi, the MIME TYPE and UTI defines which of kind of things the plugin can open.

text/* should allow you to share a text file, if you have a app that handles text files which have a "Open With..." option, your app should be listed...

My only use case was image (I think every users so far as well), so I never really explored this.

It's not impossible that the plugin needs minor adjustment to make this work, let me know if learn anything.

j3k0 avatar Mar 17 '18 00:03 j3k0

Ah perhaps I am confused. I was thinking this would be invoked from the "Share" menu with text, not from the OpenWith from a File....subtle difference I guess. I will dig some more...

viking2917 avatar Mar 17 '18 00:03 viking2917

It could be handy to support multiple mime types, e.g. both images and text. In my case, I am thinking of support for text (URLs) in addition to images. Use case being sharing image URL from e.g. Web browser or other apps.

Cheers -jo

tverilytt avatar Mar 17 '18 13:03 tverilytt

@tverilytt I'm looking for a use case where I'd just share text, more specifically URLs to my app. Did you get it working? I was going through this https://stackoverflow.com/questions/33105698/cordova-sharing-browser-url-to-my-ios-app-clipper-ios-share-extension#answer-34064913, but the code seems outdated, and there are many errors in the Swift code (which, I think is because of the age of the post).

ankitjainOfficial avatar Sep 05 '18 14:09 ankitjainOfficial

@ankitjainOfficial Hi! No, since this plugin does not support multiple mime types, I have not made any more effort on the topic. The cordova-plugin-openwith-ios, does state it supports multiple mime types, but only for IOS...: https://github.com/EternallLight/cordova-plugin-openwith-ios

Cheers -jo

tverilytt avatar Sep 05 '18 14:09 tverilytt

@ankitjainOfficial I have text sharing working. I use the openwith-ios plugin for iOS mentioned by @tverilytt (https://github.com/EternallLight/cordova-plugin-openwith-ios) and https://github.com/darryncampbell/darryncampbell-cordova-plugin-intent for Android. I don't do any image sharing. My use case is sharing text selected in the Kindle app to my app, but one can also share URLs from browsers and such.

It's been awhile since I set this up so my detailed memory is hazy but if you have specific questions would be happy to dig into it again. But the combination of these two plugins can get you there.

viking2917 avatar Sep 05 '18 14:09 viking2917

@viking2917 @tverilytt I have successfully integrated the Android side, with the intent plugin. Thanks for the iOS part. Thanks guys.

ankitjainOfficial avatar Sep 05 '18 15:09 ankitjainOfficial

@ankitjainOfficial Good to hear. Would be cool if this plugin could support this, so could do with just one plugin :-)

tverilytt avatar Sep 06 '18 14:09 tverilytt

Feel free to contribute ;-)

j3k0 avatar Sep 18 '18 17:09 j3k0

HI ! I installed the plugin but still when i mark a text and press on share option ..my app doesnt apppear among the other apps.. @viking2917 could you please show me sample code?

menachem112 avatar Jul 07 '19 17:07 menachem112

@menachem112 this is for iOS correct? If your app doesn't show on the share list, it's likely not a problem with the code per se, more likely the setup. Did you follow the instructions for setting up the App Groups? Double check in developer.apple.com under Identifiers that on your app, the App group shows as enabled? The video mentioned in the instructions shows all the details for setting up the App group. (I also had to ensure that the build targets for the app itself as well as the Share Extension were the same (9.0/universal in my case)

viking2917 avatar Jul 07 '19 19:07 viking2917

@menachem112 also: I forgot I used a small fork of this project to deal with the "not logged in" issue (https://github.com/EternallLight/cordova-plugin-openwith-ios/issues/3).

My fork is now behind master but you can try it if you want, this is the fork: https://github.com/viking2917/cordova-plugin-openwith-ios . I am honestly not sure if this is still required, I did this a long time ago. You can install it like this: cordova plugin add https://github.com/viking2917/cordova-plugin-openwith-ios.git --variable IOS_URL_SCHEME=cordovaopenwithdemo

You might find some clues here: https://github.com/j3k0/cordova-plugin-openwith/issues/41

But I suspect the issue is your app groups are somehow not configured right...

viking2917 avatar Jul 07 '19 19:07 viking2917

thanks @viking2917 , I have a problem with android too. I WOULD LIKE TO SEE A WORKING EXAMPLe

menachem112 avatar Jul 07 '19 19:07 menachem112

I don't use this for android, to be clear, just IOS, so can't help with Android.

Do you that app group setup as described for iOS?

I can't easily post any working example, my usage is integrated into a large and proprietary app. The video mentioned in the instructions contains a complete working example I believe - I'd suggest starting from that and getting that running. https://www.youtube.com/watch?v=eaE4m_xO1mg&feature=youtu.be

Or, can you post your code, what you have tried, including your xcode project? That might make it easier to spot what's going on.

viking2917 avatar Jul 07 '19 20:07 viking2917

I managed to add the following lines to enable text sharing in ShareExtension-Info.plist

<dict>
        <key>NSExtensionActivationSupportsImageWithMaxCount</key>
        <integer>1</integer>
         // Following part enables text
        <key>NSExtensionActivationSupportsText</key>
        <true/>
</dict>

windht avatar Jan 29 '20 18:01 windht