j3k0 / cordova-plugin-openwith

Get your Cordova App in the O.S. "Share" menu on iOS and Android
MIT License
137 stars 114 forks source link

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

Open viking2917 opened 6 years ago

viking2917 commented 6 years ago

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!

j3k0 commented 6 years ago

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.

viking2917 commented 6 years ago

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...

tverilytt commented 6 years ago

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

ankitjainOfficial commented 6 years ago

@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).

tverilytt commented 6 years ago

@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

viking2917 commented 6 years ago

@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.

ankitjainOfficial commented 6 years ago

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

tverilytt commented 6 years ago

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

j3k0 commented 6 years ago

Feel free to contribute ;-)

menachem112 commented 5 years ago

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?

viking2917 commented 5 years ago

@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 commented 5 years ago

@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...

menachem112 commented 5 years ago

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

viking2917 commented 5 years ago

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.

windht commented 4 years ago

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>