I am using the FirebasePushNotification plugin in my xamarin forms app, and I followed all the instruction for the set up.
https://github.com/CrossGeeks/FirebasePushNotificationPlugin
This is the third app where i use it, but it's never firing the OnTokenRefresh event in the .net standard project (App.xaml.cs). It works fine in all the other apps.
However, the event fires only if i implement in the MainApplication class:
[Application]
public class MainApplication : Application
{
public MainApplication(IntPtr handle, JniHandleOwnership transer) : base(handle, transer)
{
}
public override void OnCreate()
{
base.OnCreate();
FirebasePushNotificationManager.Initialize(this, true);
CrossFirebasePushNotification.Current.OnTokenRefresh += Current_OnTokenRefresh;
}
private void Current_OnTokenRefresh(object source, FirebasePushNotificationTokenEventArgs e)
{
// this one fires
}
In App.xaml.cs (where I need it), it doesn't:
protected override async void OnStart()
{
base.OnStart();
//----------------------- Firebase Push Notifications -----------------------//
CrossFirebasePushNotification.Current.RegisterForPushNotifications();
// token is refreshed
CrossFirebasePushNotification.Current.OnTokenRefresh += Current_OnTokenRefresh; // *********** never fires ***************
// Push message received event: while the app is in foreground
CrossFirebasePushNotification.Current.OnNotificationReceived += Current_OnNotificationReceived;
// Push message opened event: while the app ins in background
CrossFirebasePushNotification.Current.OnNotificationOpened += Current_OnNotificationOpened;
// Push message action tapped event
CrossFirebasePushNotification.Current.OnNotificationAction += Current_OnNotificationAction;
}
What could the cause be?
I am running out of ideas, i tried in android only so far, emulator and device...
Thanks
PS: I would post the question on the github page, but i almost never get an answer there so i am asking here.