question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deep-linking on Android

See original GitHub issue

I’ve run into an issue when using a deep-linking scheme for my nativescript-angular app. I can receive the Intent just fine, but the entire angular app seems to be re-initialized on each deep-link received.

Using the basic template-hello-world-ng template I’ve done this:

In AndroidManifest.xml added the following to the NativeScriptActivity:

<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="deeplink" />
</intent-filter>

And added this to AppComponent’s OnInit:

application.android.on(application.AndroidApplication.activityResumedEvent, (args) => {
    if (args.activity.getIntent().getAction() === android.content.Intent.ACTION_VIEW) {
        const intentData = args.activity.getIntent().getData();
        console.log(`Android received ACTION_VIEW intent, with data: ${intentData}`);
    }
});

Now when I launch the app, suspend it, and then launch the url “deeplink://test”, the app resumes and I can receive the intent just fine. But it seems the entire angular app and all components are initialized again from scratch, without destroying the old ones.

Test project demonstrating the issue here: https://github.com/ddfreiling/tns-ng-deeplink/tree/bug-report

Here’s my logging output when doing this:

BUILD SUCCESSFUL

Total time: 2.635 secs
Project successfully built
Successfully deployed on device with identifier '05157df5c4753b21'.
JS:  === AppComponent<1> OnInit ===
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ActivitySuspend: com.tns.NativeScriptActivity@7d77ae7
JS: ActivityResume: com.tns.NativeScriptActivity@7d77ae7
JS: ActivitySuspend: com.tns.NativeScriptActivity@7d77ae7
JS: Launched Android application with the following intent: Intent { act=android.intent.action.VIEW dat=deeplink://test flg=0x10400000 cmp=dk.nota.deeplink.test/com.tns.NativeScriptActivity }.
JS: ActivityResume: com.tns.NativeScriptActivity@e93a5ac
JS: - Android received ACTION_VIEW intent, with data: deeplink://test
JS:  === AppComponent<2> OnInit ===
JS: Angular 2 is running in the development mode. Call enableProdMode() to enable the production mode.
JS: ActivitySuspend: com.tns.NativeScriptActivity@e93a5ac
JS: ActivitySuspend: com.tns.NativeScriptActivity@e93a5ac
JS: ActivityResume: com.tns.NativeScriptActivity@e93a5ac
JS: ActivityResume: com.tns.NativeScriptActivity@e93a5ac
JS: - Android received ACTION_VIEW intent, with data: deeplink://test
JS: - Android received ACTION_VIEW intent, with data: deeplink://test

It also seems I’m receiving the ACTION_VIEW intent again when I just exit the app and resume normally, without using a deep link (after having received one earlier).

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ddfreilingcommented, Feb 14, 2017

@dameety Nope, no response from the dev team, and I haven’t found a way to fix it myself yet.

1reaction
dameetycommented, Feb 14, 2017

HI @ddfreiling, Did you get this to work? i wanna include the deep link feature in my app and needed a guide to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Deep Links to App Content - Android Developers
To allow users to enter your app from links, you must add intent filters for the relevant activities in your app manifest. These...
Read more >
Deep Linking in Android with Example - GeeksforGeeks
Deep Linking is one of the most important features that is used by various apps to gather data inside their apps in the...
Read more >
Intro to Deep Linking on Android - Medium
A deep link is an intent filter system that allows users to directly enter a specific activity in an Android app. However there...
Read more >
Deep Linking on Android - Level Up Coding
A deep link is an intent filter system that allows users to directly enter a specific activity in an Android app. However there...
Read more >
Deep Links in Android: Getting Started - RayWenderlich.com
Deep Links in Android: Getting Started ... Having URLs that redirect to specific parts of an app is useful in marketing and user...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found