Deep-linking on Android
See original GitHub issueI’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:
- Created 7 years ago
- Reactions:6
- Comments:6 (3 by maintainers)
@dameety Nope, no response from the dev team, and I haven’t found a way to fix it myself yet.
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.