[Bug] NullReferenceException at Plugin.FirebasePushNotifications.Platforms.FirebasePushNotificationManagerBase.set_NotificationCategories(NotificationCategory[] value)
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
Not cool. I try to reproduce it tomorrow 👍🏻 Thanks for reporting.
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: @.***>
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.
@NGumby can you try with the latest 2.4.x pre-release nuget?
I have tried it and it's fixed! Thanks again!