Skip to content
This repository was archived by the owner on Feb 10, 2023. It is now read-only.

Commit 76ceef4

Browse files
committed
fix(action-error): Resolve action error on android
1 parent 3ee1f62 commit 76ceef4

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Replace *myapp* with your desired scheme and set launchMode to *singleTask*
8989
For example:
9090

9191
```xml
92-
<activity android:name="com.tns.NativeScriptApplication" android:label="@string/app_name" android:launchMode="singleTask">
92+
<activity android:name="com.tns.NativeScriptApplication" android:label="@string/app_name" android:launchMode="singleTop">
9393
<intent-filter>
9494
<action android:name="android.intent.action.MAIN" />
9595
<category android:name="android.intent.category.LAUNCHER" />

urlhandler.android.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@ export function handleIntent(intent: any) {
99
let data = intent.getData();
1010
if (lastReceivedData === null || data.toString() !== lastReceivedData.toString()) {
1111
try {
12-
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
12+
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
13+
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
1314
try {
14-
setTimeout(() => {
15-
getCallback()(extractAppURL(data));
16-
});
15+
setTimeout(() => getCallback()(extractAppURL(data)));
1716
} catch (ignored) {
1817
application.android.on(application.AndroidApplication.activityResultEvent, (eventData) => {
19-
setTimeout(() => {
20-
getCallback()(extractAppURL(data));
21-
});
18+
setTimeout(() => getCallback()(extractAppURL(data)));
2219
});
2320
}
2421
}
2522
} catch (e) {
2623
console.error('Unknown error during getting App URL data', e);
2724
}
25+
lastReceivedData = data;
2826
}
2927
}
3028
application.android.on(application.AndroidApplication.activityCreatedEvent, (args) => {
3129
let intent: android.content.Intent = args.activity.getIntent();
3230
try {
33-
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
34-
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
35-
handleIntent(intent);
36-
}
31+
handleIntent(intent);
3732
} catch (e) {
3833
console.error('Unknown error during getting App URL data', e);
3934
}
@@ -42,11 +37,7 @@ application.android.on(application.AndroidApplication.activityCreatedEvent, (arg
4237
application.android.on(application.AndroidApplication.activityResumedEvent, (args) => {
4338
let intent: android.content.Intent = args.activity.getIntent();
4439
try {
45-
if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf()
46-
|| new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) {
47-
handleIntent(intent);
48-
lastReceivedData = intent.getData();
49-
}
40+
handleIntent(intent);
5041
} catch (e) {
5142
console.error('Unknown error during getting App URL data', e);
5243
}

0 commit comments

Comments
 (0)