1

I want to open my Application Android (Nativescript) from a link in email, that is Click here to reset password

http://XX.XXX.XX.XX:XXXX/reset/1234567891011121314

.so when I click the link from my mobile browser I need the app Launched.

Is there any solution for this?

Update code:

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
        <action android:name="android.intent.action.VIEW" />
    </intent-filter>
    <intent-filter android:autoVarify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="http" android:host="xx.xxx.xx.xx" android:port="xxxx" android:path="reset">
        </data>
    </intent-filter>

I change link to

http://mydomain.tk/v1/reset/1234567891011121314

<data android:scheme="http" android:host="mydomain.tk" android:path="/v1/reset">

doesn't work again.

au bina
  • 63
  • 1
  • 7
  • Possible duplicate of [How to launch app on click of url in android](https://stackoverflow.com/questions/41807300/how-to-launch-app-on-click-of-url-in-android) – ADM Dec 06 '18 at 15:41

2 Answers2

0

I use the following code :

<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

Owen Selles
  • 38
  • 1
  • 7
  • I try like you say but doesn't work. For me work only when I use https. Any idea please, how to work with http ? – au bina Dec 12 '18 at 10:16
0

Android

Add intent filter to your activity in AndroidManifest.xml

<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:scheme="myapp" /> 
</intent-filter>

You may even use a web url for deep linking

<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:scheme="http"
    android:host="XXXX"
    android:port="XXXX"
    android:path="reset"></data>
</intent-filter>

iOS

Add CFBundleURLTypes to Info.plist file

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLName</key>
        <string>com.yourcompany.myapp</string>
    </dict>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
        </array>
    </dict>
</array>

It's not possible to use web urls for deep linking in iOS. A workaround is to check whether the current device is iOS and launch app from your webpage.

If you want to handle the parameters passed in the URL, then you must use nativescript-urlhandler plugin.

Manoj
  • 21,753
  • 3
  • 20
  • 41
  • Thank you for your comment. `Error is: Socket connection timeouted..` – au bina Dec 07 '18 at 09:30
  • The error is no where related to this topic. It must be something to do with your CLI. Refer similar issues on SO and forums. – Manoj Dec 07 '18 at 09:34
  • This error show only when I put this code, when I remove it, the error don't show – au bina Dec 07 '18 at 10:01
  • Are you sure the error goes away when you remove these changes? – Manoj Dec 07 '18 at 10:10
  • That's unfortunate, I have this in almost every app and I never hit such issue. Are you on latest CLI? Does this happen only for Android or iOS too? – Manoj Dec 07 '18 at 11:34
  • I solution this error. Now, I can't understand how to use this. Link from email open in browser, not in app. I have Android App, work with Nativescript! – au bina Dec 07 '18 at 13:31
  • If you have configured everything properly, then you must get a intent picker dialog asking you to choose between browser and your app upon clicking on the link, assuming you are using HTTP link. – Manoj Dec 07 '18 at 13:34
  • I configurate like in my update post. Can you see please? – au bina Dec 07 '18 at 13:41
  • I'm unsure whether IP address as value for `android:host` works, at least I never tried it. In general links sent in email never be an IP address but a valid domain name. So try using a domain name and see if that works. – Manoj Dec 08 '18 at 17:39
  • can you see again my post please? It's important that domain to be www.mydomain.tk ?? – au bina Dec 12 '18 at 09:23