I’m making an attempt to ship distant notifications in my cellular app constructed utilizing Xamarin.Types. I’ve made all the required console settings in Firebase and uploaded google-services.json and GoogleService-info.plist. The notification perform works completely fantastic with Xamarin.Types android however the identical code doesn’t work for Xamarin types iOS.
My App.xamal.cs:
public partial class App : Software
{
public App()
{
InitializeComponent();
CrossFirebasePushNotification.Present.OnTokenRefresh += (s, p) => {
string token = p.Token;
System.Diagnostics.Debug.WriteLine($"TOKEN REFRESHED: {token}");
_ = MyService.UpdateUserDeviceToken(token);
};
}
...
}
And that is how my AppDelegate is saved:
namespace MyApp.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : international::Xamarin.Types.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary choices)
{
international::Xamarin.Types.Types.Init();
LoadApplication(new App());
FirebasePushNotificationManager.Initialize(choices, true);
return base.FinishedLaunching(app, choices);
}
public override void RegisteredForRemoteNotifications(UIApplication utility, NSData deviceToken)
{
FirebasePushNotificationManager.DidRegisterRemoteNotifications(deviceToken);
}
public override void FailedToRegisterForRemoteNotifications(UIApplication utility, NSError error)
{
FirebasePushNotificationManager.RemoteNotificationRegistrationFailed(error);
}
public override void DidReceiveRemoteNotification(UIApplication utility, NSDictionary userInfo, Motion<UIBackgroundFetchResult> completionHandler)
{
FirebasePushNotificationManager.DidReceiveMessage(userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}
public override void WillEnterForeground(UIApplication uiApplication)
{
LocalNotificationCenter.ResetApplicationIconBadgeNumber(uiApplication);
base.WillEnterForeground(uiApplication);
}
}
}
Together with this, I’ve additionally enabled Push notifications in Entitlements.plist and in addition in Information.plist enabled Distant Notification in Background Modes and in addition added
FirebaseAppDelegateProxyEnabled
However nonetheless, it doesn’t set off on refresh token occasion. This factor works completely fantastic with android and the refresh token is triggered. I’ve taken reference to this nugget package deal Plugin.PushNotification