Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
70
rated 0 times [  77] [ 7]  / answers: 1 / hits: 25389  / 10 Years ago, tue, january 20, 2015, 12:00:00

I found many answers for a custom URL-Scheme like this (mycoolapp://somepath).



This plugin for example adds a custom URL-Sheme.*



But I don't want a custom URL-Scheme, I want a normal URL like this (http://www.mycoolapp.com/somepath).



If you open this in you Browser or click on a Hyperlink for example, then it should ask you to open my app (like google maps does it).



This question maybe already has an answer, but i can't find it.



If you don't know what I mean, that's how it should look if you click on the link to my website on an Android Device:



application



Just with my app to select.


More From » cordova

 Answers
38

For the same problem I've used existing webintent plugin, modified the android manifest file - add those lines to activity



<intent-filter>
<action android:name=android.intent.action.VIEW />
<category android:name=android.intent.category.DEFAULT />
<category android:name=android.intent.category.BROWSABLE />
<data android:host=example.com android:scheme=http />
</intent-filter>


and modified the index.html ondeviceready:



function deviceReady() {
window.plugins.webintent.getUri(function(url) {
console.log(INTENT URL: + url);
//...
});
}


EDIT



I've just noticed a behavior which may be unwanted. When you open the app using the link (intent) from another application, it will (in many cases) create a new instance and not use the already running one (tested with gmail and skype). To prevent this a solution is to change Android Launch mode in config.xml file:



<preference name=AndroidLaunchMode value=singleTask />


(It works with cordova 3.5, not sure about the older version)



Then you need to add one more function to ondeviceready:



window.plugins.webintent.onNewIntent(function(url) {
console.log(INTENT onNewIntent: + url);
});


This one is triggered when the app was already running and was brought to front with intent.


[#68159] Friday, January 16, 2015, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
piper

Total Points: 734
Total Questions: 93
Total Answers: 112

Location: Burundi
Member since Wed, Apr 6, 2022
2 Years ago
piper questions
Thu, Apr 22, 21, 00:00, 3 Years ago
Thu, Mar 11, 21, 00:00, 3 Years ago
Wed, Jun 12, 19, 00:00, 5 Years ago
Tue, Jun 11, 19, 00:00, 5 Years ago
;