NativeScript / nativescript-angular

Integrating NativeScript with Angular
http://docs.nativescript.org/angular/tutorial/ng-chapter-0
Apache License 2.0
1.21k stars 241 forks source link

Deep Link opened with Safari instead of app #1881

Open panagulis72 opened 5 years ago

panagulis72 commented 5 years ago

I have to share a link (of the app itself). So taping on share button the application shares the url of a page inside. Then, the user which views the link and tap on it, should open directly with the (same) installed app. This works fine in Android, and this is a piece of Manifest:

<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="www.test.com" />
            <data android:scheme="https" />
</intent-filter>

I'm using the SocialShare plugin to share the url:

share() {
    let url = this.router.url;
    SocialShare.shareUrl("http://www.test.com" + url, "http://www.test.com" + url);
 }

This works fine in Android. But I have an issue in IOS, because it opens the link with safari. This a piece of Info.plist file:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>mytestapp</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>http://www.test.com</string>
            </array>
        </dict>

I tried to use just 'test' on info.plist schema, and then I tried to share the following url: test://my_custom_routing and it works fine in IOS, but it doesn't work on Android (it doesn't recognize it as an url). So the unique and possible way I can see is to use the "http://" for the link. But it doesn't work on IOS. What am I doing wrong?

tsonevn commented 5 years ago

Hi @panagulis72, If I understand correctly, you want to set up a universal link, which allows opening the app, when you request a specific link. If so, you might need to make some extra configurations in the app and the site. I've made a little research and found this article, that can help you in solving your case. Let me know whether this helps.