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

问题描述 投票:0回答:1

我已经在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 firebase push-notification nativescript nativescript-angular
1个回答
0
投票

当向AndroidManifestis添加android:launchMode =“ singleTask”时有效

© www.soinside.com 2019 - 2024. All rights reserved.