This question already has answers here:
Closed 2 years ago.
I want to open my app from an email URL, basically like the example shown below for Twitter.com.
Email with link:
Selection to open app or browser:
After you click on the app choice, the Twitter app opens:
I tried the following code, but it is not working:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:host="www.twitter.com" android:scheme="http"></data>
</intent-filter>
If anyone has a proper answer, please write some examples here.
The following code worked for me:
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data
android:host="www.my.app.com"
android:path="launch"
android:scheme="http"></data>
</intent-filter>
With the email link set as http://www.my.app.com/launch
.
Ref: Launching Android Application from link or email
Ex: Your url will be something like https://roadies.com and you have the intent filter in manifest as below
android:name="com.droid.MainActivity"
android:label="@string/app_name" >
<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="roadies.com"
android:scheme="https" />
</intent-filter>
</activity>
For me, none of the answers posted here worked. I tried tens of different syntaxes without any success. I was getting a parsing error while building the app via Cordova.
I finally encountered this answered which led me on the right track.
So I created a hook in the PROJECT_ROOT/hooks/after_prepare/
folder called 010_add_intent_filters.sh
. Here is the content of this hook :
!/usr/bin/bash
MANIFEST=./platforms/android/AndroidManifest.xml
grep -q pathPattern $MANIFEST && { print "Manifest already modified. Nothing to do."; exit 0; }
AFTER_LINE='android:name="MainActivity"'
ADDITION='\
<intent-filter>\
<action android:name="android.intent.action.VIEW"></action>\
<category android:name="android.intent.category.DEFAULT"></category>\
<category android:name="android.intent.category.BROWSABLE"></category>\
<data android:scheme="https" android:host="google.com" android:pathPattern=".*"></data>\
</intent-filter>
';
sed -i -e "/${AFTER_LINE}/a${ADDITION}" $MANIFEST
This finally worked. No modification to config.xml
is required if you take the hook path. I hope this helps someone in need.
PS: I am convinced Cordova is a great technology, but I have rarely seen such a badly documented library... How painful it is to work with it is just unbelievable.