From 3ee1f62fa19b9016fc14253127117231f60aad1b Mon Sep 17 00:00:00 2001 From: Martin Reinhardt Date: Thu, 6 Apr 2017 14:29:36 +0200 Subject: [PATCH] fix(Action-Error): Solve Android action error see #22 --- urlhandler.android.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/urlhandler.android.ts b/urlhandler.android.ts index 9d1981e..171d727 100644 --- a/urlhandler.android.ts +++ b/urlhandler.android.ts @@ -10,11 +10,17 @@ export function handleIntent(intent: any) { if (lastReceivedData === null || data.toString() !== lastReceivedData.toString()) { try { if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) { - application.android.on(application.AndroidApplication.activityResultEvent, (eventData) => { + try { setTimeout(() => { getCallback()(extractAppURL(data)); }); - }); + } catch (ignored) { + application.android.on(application.AndroidApplication.activityResultEvent, (eventData) => { + setTimeout(() => { + getCallback()(extractAppURL(data)); + }); + }); + } } } catch (e) { console.error('Unknown error during getting App URL data', e); @@ -25,7 +31,7 @@ application.android.on(application.AndroidApplication.activityCreatedEvent, (arg let intent: android.content.Intent = args.activity.getIntent(); try { if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf() - || new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) { + || new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) { handleIntent(intent); } } catch (e) { @@ -37,7 +43,7 @@ application.android.on(application.AndroidApplication.activityResumedEvent, (arg let intent: android.content.Intent = args.activity.getIntent(); try { if (new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_MAIN).valueOf() - || new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) { + || new String(intent.getAction()).valueOf() === new String(android.content.Intent.ACTION_VIEW).valueOf()) { handleIntent(intent); lastReceivedData = intent.getData(); }