Custom-URL-scheme
Custom-URL-scheme copied to clipboard
How to add a host?
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.
What's the code you were trying to add to your comment?
Updated.
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
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
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.
Yes that's what I want. @FreakTheMighty any idea?
@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.
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>
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...
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.
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
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
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.
@EddyVerbruggen Any news with adding host support for the plugin?
:+1:
Adding host supported for the plugin ?
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.