Custom-URL-scheme icon indicating copy to clipboard operation
Custom-URL-scheme copied to clipboard

How to add a host?

Open animista01 opened this issue 11 years ago • 17 comments

How can I add a host to watch for?

This code: data android:host="mysite.com" android:path="/hi" android:scheme="http"

But it doesn't work.

animista01 avatar Aug 18 '14 23:08 animista01

What's the code you were trying to add to your comment?

EddyVerbruggen avatar Aug 21 '14 17:08 EddyVerbruggen

Updated.

animista01 avatar Aug 21 '14 19:08 animista01

I need a bit more details. Where do you add the code? How are you building (local or build.phonegap.com)? Sharing your entire project would help as well. Thx

EddyVerbruggen avatar Aug 22 '14 05:08 EddyVerbruggen

Is local. What I want is to share an url of my web page to a person and when the url match with the host that I set up in the intent-filter it will open my app, if the user has my app. This http://developer.android.com/guide/topics/manifest/data-element.html

animista01 avatar Aug 27 '14 21:08 animista01

Hey @EddyVerbruggen I think that @animista01 is looking to implement something like this:

http://stackoverflow.com/a/12901352/196048

By adding the data node to the intent you can have certain urls launch the app. The benefit of this over a custom scheme is that you can use it to redirect the user to the Android app store if they don't have the app.

FreakTheMighty avatar Nov 04 '14 00:11 FreakTheMighty

Yes that's what I want. @FreakTheMighty any idea?

animista01 avatar Nov 04 '14 02:11 animista01

@animista01 This is what I've come up with:

https://github.com/FreakTheMighty/LaunchMyApp-PhoneGap-Plugin/commit/222bcf023cdbe1e89d992c10bbd79ee334cda8e5

This works for me, to make it into a proper merge request, I'm sure those values need to be optional.

FreakTheMighty avatar Nov 04 '14 02:11 FreakTheMighty

The idea of @animista01 seems worth the effort. I've added it to my app and its working. Now my users will be able to send links and the recipient will be taken to the shared item, no matter if he has the app. Combined with a landing page as a fallback, the solution is nearly perfect.

@EddyVerbruggen, should your plugin be able to resolve custom hosts?

//original intent
<intent-filter android:label="@string/launcher_name">
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

//custom URL
<intent-filter>
    <data android:host="www.MYDOMAIN.es" android:pathPrefix="/test" android:scheme="http" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

//plugin's own intent
<intent-filter>
    <data android:scheme="mycoolapp" />
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

rotoxl avatar Aug 21 '15 10:08 rotoxl

Awesome guys, I really like it. It resembles what Apple has added with iOS: Universal Links.

I'm not sure I can pull it off to add the iOS implementation to this plugin without breaking things for current users, but let's add this for Android nonetheless. Working on it...

EddyVerbruggen avatar Sep 14 '15 19:09 EddyVerbruggen

Struggling a bit with this.. although plugin spec says a --variable is mandatory when it's added as a <preference> in plugin.xml, it won't be replaced by the passed-in value when it's not marked as a preference. Meaning: I must add the them as <preference>s for Android. Bummer there. I'll be digging in the plugman source before going forward.

Question: would you guys rather have a separate URL_SCHEME and a new intent filter with HOST PATH and SCHEME (not settled on the naming yet), or would one intent suffice, so I simply add HOST and PATH to the current filter (and you'd pass in --variable HOST= --variable PATH= to get the current behaviour. Downside of the former is you'll need to add a SCHEME variable on top of the URL_SCHEME which may confuse the hell out of users. An advantage is you'd be able to add more than one scheme/intent filter to your app via this plugin, but that's not a very common case methinks.

EddyVerbruggen avatar Sep 14 '15 20:09 EddyVerbruggen

It's great news that iOS will also support these links.

In response to @EddyVerbruggen's question: i would say that just one intent suffices, I agree It doesn't seem a common case to have more than one scheme mapped in your app. And anyway, it could be offered as a manual recipe for those who require it.

Thanks again Eddy

rotoxl avatar Sep 15 '15 14:09 rotoxl

Good news indeed!

About time Apple released that feature.

How could we manage the creation of multiple intents? For example, you'd like to intercept the http and the https schemes for your domain

schoettler avatar Sep 15 '15 14:09 schoettler

bump. @EddyVerbruggen this would be a nice addon. as of now i just added <data android:host="www.example.com" android:pathPattern=".*" android:scheme="http" /> to the plugin's xml.

mohitmayank avatar Sep 21 '15 08:09 mohitmayank

@EddyVerbruggen Any news with adding host support for the plugin?

virtser avatar Oct 17 '15 10:10 virtser

:+1:

diegobill avatar Dec 08 '15 02:12 diegobill

Adding host supported for the plugin ?

KartikDomadiya avatar Feb 18 '17 10:02 KartikDomadiya

Yes. This feature is required. One usecase is: If app is not installed, we should send user to Play Store. For this, we need to add the host.

FYI: https://github.com/ionic-team/ionic-plugin-deeplinks plugin has support for adding host & port.

CatchSandeepVaid avatar Jul 13 '17 14:07 CatchSandeepVaid