Plugin.FirebasePushNotifications icon indicating copy to clipboard operation
Plugin.FirebasePushNotifications copied to clipboard

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

Open NGumby opened this issue 6 months ago • 2 comments

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

  • Version with issue: 2.3.12
  • Last known good version: never

Screenshots

Reproduction Link

NGumby avatar Aug 21 '24 20:08 NGumby