thomasgalliker / Plugin.FirebasePushNotifications

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

[Bug] NullReferenceException at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.set_NotificationCategories(NotificationCategory[] value) #55

Open NGumby opened 3 weeks ago

NGumby commented 3 weeks ago

Description

When calling RegisterNotificationCategories too early, you get a NullReferenceException

Steps to Reproduce

In my MainPage constructor, I call this code :

       CrossFirebasePushNotification.Current.TokenRefreshed += OnTokenRefresh;
       CrossFirebasePushNotification.Current.NotificationOpened += OnNotificationOpenedAsync;
       CrossFirebasePushNotification.Current.NotificationReceived += OnNotificationReceivedAsync;
       CrossFirebasePushNotification.Current.NotificationDeleted += OnNotificationDeletedAsync;
       CrossFirebasePushNotification.Current.NotificationAction += OnNotificationActionAsync;

       var notificationCategories = new NotificationCategory[]
          {
               new NotificationCategory("dismiss",new NotificationAction[] {
                   new NotificationAction("Dismiss","Dismiss", NotificationActionType.Default),
               }),
               new NotificationCategory("navigate",new NotificationAction[] {
                   new NotificationAction("Dismiss","Dismiss", NotificationActionType.Default),
                   new NotificationAction("Navigate","Navigate To", NotificationActionType.Foreground)
               })
       };
       CrossFirebasePushNotification.Current.RegisterNotificationCategories(notificationCategories);

Expected Behavior

Actual Behavior

---> System.NullReferenceException: Object reference not set to an instance of an object. at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.set_NotificationCategories(NotificationCategory[] value) at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.RegisterNotificationCategories(NotificationCategory[] notificationCategories)

Basic Information

Screenshots

Reproduction Link

thomasgalliker commented 3 weeks ago

Not cool. I try to reproduce it tomorrow πŸ‘πŸ» Thanks for reporting.

NGumby commented 3 weeks ago

Forgot to say that it works if I do that later in the pipeline.

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: Thomas Galliker @.> Sent: Wednesday, August 21, 2024 5:08:44 PM To: thomasgalliker/Plugin.FirebasePushNotifications @.> Cc: NGumby @.>; Author @.> Subject: Re: [thomasgalliker/Plugin.FirebasePushNotifications] [Bug] NullReferenceException at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.set_NotificationCategories(NotificationCategory[] value) (Issue #55)

Not cool. I try to reproduce it tomorrow πŸ‘πŸ» Thanks for reporting.

β€” Reply to this email directly, view it on GitHubhttps://github.com/thomasgalliker/Plugin.FirebasePushNotifications/issues/55#issuecomment-2303016610, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABKES24TPW4HTTEJYUOC6YDZST6VZAVCNFSM6AAAAABM4ZZW2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBTGAYTMNRRGA. You are receiving this because you authored the thread.Message ID: @.***>

thomasgalliker commented 3 weeks ago

This issue involves a refactoring in the initialization process of the library. Not very easy stuff. I started working on a new branch but it will take some days to release a test version of the nuget.

thomasgalliker commented 23 hours ago

@NGumby can you try with the latest 2.4.x pre-release nuget?