Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I get this receiving a URL from a browser? #102

Open
bedfl2016 opened this issue Apr 11, 2020 · 15 comments
Open

How do I get this receiving a URL from a browser? #102

bedfl2016 opened this issue Apr 11, 2020 · 15 comments

Comments

@bedfl2016
Copy link

How do I get this plugin receiving a URL from a browser?

@MrXyfir
Copy link

MrXyfir commented May 11, 2020

Any luck?

@EternallLight
Copy link

EternallLight commented May 11, 2020

For iOS, add

<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>10</integer>

to your share extension .plist file under NSExtensionActivationRule section

@bedfl2016
Copy link
Author

Thank you, is there a way to do this on android?

@EternallLight
Copy link

For Android, paste the following into your AndroidManifest.xml file:

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>

This will make your app accept any type of files, including links. If you need to restrict to links only, examine what mime is coming when you're sharing links with the configuration above and them replace / with what you found.
It will probably be text/plain.

@MrXyfir
Copy link

MrXyfir commented May 11, 2020

Ended up using https://github.com/missive/cordova-plugin-openwith and setup was super easy. Make sure to add via the git repo.

Not sure how it differs from Eternal's which it was forked from...

@bedfl2016
Copy link
Author

Ok thanks for the help! I am going to look at the github link!

@josiahbryan
Copy link

Thanks @MrXyfir !!! That worked PERFECTLY (the missive plugin) - I've been trying for TWO HOURS to get something to recognize plain text shares in Android and iOS - and NOTHING worked out of the box until I found your link to the missive plugin.

For the record, here is how I added it:

cordova plugin add https://github.com/missive/cordova-plugin-openwith.git \
  --variable ANDROID_MIME_TYPE="text/*" \
  --variable IOS_URL_SCHEME=myversesapp \
  --variable IOS_UNIFORM_TYPE_IDENTIFIER=public.plain-text \
  --variable IOS_BUNDLE_IDENTIFIER=com.josiahbryan.myverses

On Android, the item in intent.items[0] is:

{
    data: "lorem ipsum",
    type: "text/plain"
}

On iOS 13, the same intent.items[0] comes as:

{
    data: "lorem ipsum",
    type: "public.text"
    // other misc iOS-specific keys here, but nothing I cared about
}

If only I had tried that plugin two hours ago LOL - anyway, thanks!!

@MrXyfir
Copy link

MrXyfir commented May 18, 2020

@josiahbryan 2 hours? Rookie numbers! I spent like two days trying to get these stupid plugins to work! Glad I could help though.

@HarelM
Copy link
Contributor

HarelM commented Jul 28, 2020

@EternallLight or anyone else who knows - Can you elaborate on how to make this plugin receive urls from a specific site - i.e. universal links?
I would like my iOS app to open a url that is sent in whatsapp/facebook/mail etc - i.e. www.mysite.com/product/1234 and open the relevant page in my app.
I was able to do it for android with tons of intent-filters and I would like to do the same for iOS, or at least partially.
My config.xml can be seen here (you can scroll up and down to see how many intents I have added):
https://github.com/IsraelHikingMap/Site/blob/9fef9192788a042aaee594854969a99b059ba1da/IsraelHiking.Web/config.xml#L133L143

Can any of you elaborate on the equivalent in iOS?
Do I need to add some lines like the following to my ShareExtension-Info.plist file using the config.xml file?

<edit-config target="NSExtensionActivationRule" file="ShareExtension-Info.plist" mode="merge">
    <key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
    <integer>10</integer>
</edit-config>

Any help would be appreciated.

@MrXyfir
Copy link

MrXyfir commented Jul 28, 2020

@HarelM That's not what this plugin is for. You need a plugin specifically for universal links like https://github.com/GEDYSIntraWare/cordova-universal-links-plugin which is a fork of the original deprecated plugin https://github.com/nordnet/cordova-universal-links-plugin

There are many forks available so you have to test and find one that works for you.

@HarelM
Copy link
Contributor

HarelM commented Jul 28, 2020

@MrXyfir It works for android, also I found this information on predicate so I think it's possible for ios too :-)
https://developer.apple.com/forums/thread/75628

@j-d-carmichael
Copy link

related: #117

@Saqib92
Copy link

Saqib92 commented Aug 21, 2021

For Android, paste the following into your AndroidManifest.xml file:

            <intent-filter>
                <action android:name="android.intent.action.SEND" />
                <action android:name="android.intent.action.SEND_MULTIPLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="*/*" />
            </intent-filter>

This will make your app accept any type of files, including links. If you need to restrict to links only, examine what mime is coming when you're sharing links with the configuration above and them replace / with what you found.
It will probably be text/plain.

I tried all mimeTypes but nothing is working. even with */* I am unable to retrieve URL or Text. Images and Videos are working fine.

@j-d-carmichael
Copy link

j-d-carmichael commented Aug 22, 2021

I gave up on cordova and use capacitor js instea: https://capacitorjs.com/

Everything works out of the box very well.

There is 1 share plugin that works well except for sharing images:
https://github.com/carsten-klaffke/send-intent

The only drawback beween cordova and capacitorjs so far has been the lack of good status bar support. In cordova they manage to push the view down.. in capacitor you have to make use of the safari safe zones with CSS.. other that that though it all just worked out of the box so far very well.

@alextapia007
Copy link

on android try:
#27 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants