Nativescript Angular 应用程序在收到第二个推送通知时崩溃



我在 Nativescript Angular 中为 Android 和 IOS 开发了一个应用程序。当我向Android应用程序发送推送通知并且该应用程序在后台运行时,可以毫无问题地打开第一个通知。但是,如果我尝试打开第二个通知,应用程序将崩溃并显示以下错误

System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to destroy activity {myapp/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onDestroy failed
System.err: Error: View not added to this instance. View: Frame(274) CurrentParent: undefined ExpectedParent: AppHostView(1)
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to destroy activity {com.communithings.vrt/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onDestroy failed
System.err: Error: View not added to this instance. View: Frame(274) CurrentParent: undefined ExpectedParent: AppHostView(1)
System.err:     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4204)
System.err:     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4222)
System.err:     at android.app.ActivityThread.-wrap6(ActivityThread.java)
System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1539)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     at android.os.Looper.loop(Looper.java:154)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6121)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onDestroy failed
System.err: Error: View not added to this instance. View: Frame(274) CurrentParent: undefined ExpectedParent: AppHostView(1)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1242)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1122)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1109)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1089)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1081)
System.err:     at com.tns.NativeScriptActivity.onDestroy(NativeScriptActivity.java:39)
System.err:     at android.app.Activity.performDestroy(Activity.java:6925)
System.err:     at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1154)
System.err:     at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4191)
System.err:     ... 9 more

看起来应用程序会转到onDestroy并在尝试打开通知时完全重新启动。但是我只在打开第二个通知时遇到问题。

我的应用正在使用

Nativescript 6.3.0
tns-core-modules has 6.3.2 version
tns-android has 6.3.1 version 
tns-ios has 6.3.0 version 

关于如何解决这个问题的任何想法?

当 android:launchMode="singleTask" 添加到 AndroidManifestis 时,它可以工作

我认为你应该将你的页面路由器出口包装在 StackLayout 中,我设置了这个,通过这样做修复了:

在你的应用组件.html:

<StackLayout> 
<page-router-outlet></page-router-outlet>
</StackLayout>

最新更新