thomasgalliker / Plugin.FirebasePushNotifications

Receive and handle firebase push notifications in .NET MAUI apps
MIT License
66 stars 5 forks source link

[Bug] Android app crashes if push notification is opened from background #14

Closed thomasgalliker closed 6 months ago

thomasgalliker commented 6 months ago

Description

Android app crashes if push notification is opened from background.

Steps to Reproduce

  1. Forcibly close Android app.
  2. Send push notification to specific device.
  3. Notification appears in notification tray.
  4. Tap notification to open the app with the notification.

Expected Behavior

Actual Behavior

Basic Information

Stacktrace

Time    Device Name Type    PID Tag Message
05-08 11:32:09.196  Samsung SM-G970F    Info    20415   MonoDroid   android.runtime.JavaProxyThrowable: [Newtonsoft.Json.JsonSerializationException]: Self referencing loop detected for property 'ClassLoader' with type 'Java.Lang.ClassLoaderInvoker'. Path '[0].Data['gcm.n.analytics_data'].ClassLoader.Parent.Class'.
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeDictionary(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(Unknown Source:0)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(Unknown Source:0)
    at Newtonsoft.Json.JsonSerializer.SerializeInternal(Unknown Source:0)
    at Newtonsoft.Json.JsonSerializer.Serialize(Unknown Source:0)
    at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Unknown Source:0)
    at Newtonsoft.Json.JsonConvert.SerializeObject(Unknown Source:0)
    at Newtonsoft.Json.JsonConvert.SerializeObject(Unknown Source:0)
    at Plugin.FirebasePushNotifications.Model.Queues.PersistentQueue`1[[Plugin.FirebasePushNotifications.FirebasePushNotificationResponseEventArgs, Plugin.FirebasePushNotifications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].WriteQueueFile(Unknown Source:0)
    at Plugin.FirebasePushNotifications.Model.Queues.PersistentQueue`1[[Plugin.FirebasePushNotifications.FirebasePushNotificationResponseEventArgs, Plugin.FirebasePushNotifications, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].Enqueue(Unknown Source:0)
    at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.RaiseOrQueueEvent(Unknown Source:0)
    at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.HandleNotificationOpened(Unknown Source:0)
    at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManager.ProcessIntent(Unknown Source:0)
    at Plugin.FirebasePushNotifications.MauiAppBuilderExtensions+<>c.<UseFirebasePushNotifications>b__0_7(Unknown Source:0)
    at Microsoft.Maui.MauiApplication+ActivityLifecycleCallbacks+<>c__DisplayClass0_0.<OnActivityCreated>b__0(Unknown Source:0)
    at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents(Unknown Source:0)
    at Microsoft.Maui.MauiApplication+ActivityLifecycleCallbacks.OnActivityCreated(Unknown Source:0)
    at Android.App.Application+IActivityLifecycleCallbacksInvoker.n_OnActivityCreated_Landroid_app_Activity_Landroid_os_Bundle_(Unknown Source:0)
    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPLL_V(Unknown Source:0)
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Unknown Source:0)
    at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualVoidMethod(Unknown Source:0)
    at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod(Unknown Source:0)
    at Android.App.Activity.OnCreate(Unknown Source:0)
    at Microsoft.Maui.MauiAppCompatActivity.OnCreate(Unknown Source:0)
    at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(Unknown Source:0)
    at Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PPL_V(Unknown Source:0)
    at crc6488302ad6e9e4df1a.MauiAppCompatActivity.n_onCreate(Native Method)
    at crc6488302ad6e9e4df1a.MauiAppCompatActivity.onCreate(MauiAppCompatActivity.java:49)
    at android.app.Activity.performCreate(Activity.java:8290)
    at android.app.Activity.performCreate(Activity.java:8270)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1329)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4085)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4277)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8751)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
thomasgalliker commented 6 months ago

Serialization of Java.Lang.* data types in Intent.Extras seems to be a problem for the PersistentQueue. This requires some conversion logic.