【问题标题】:Nativescript Angular app crashes when receiving the second push notificationNativescript Angular 应用程序在收到第二个推送通知时崩溃
【发布时间】:2020-02-04 08:06:07
【问题描述】:

我在 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" 添加到我的 AndroidManifest 时,它看起来有效

标签: android firebase push-notification nativescript nativescript-angular


【解决方案1】:

将 android:launchMode="singleTask" 添加到 AndroidManifestis 时有效

【讨论】:

【解决方案2】:

我认为你应该将你的 page-router-outlet 包装在 StackLayout 中,我遇到了这个,通过这样做修复了:

在您的 app.component.html 中:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多