Hello,
Welcome to our Microsoft Q&A platform!
I check the the source code of FirebasePushNotificationPlugin
you used, we can see the following code in RegisterForPushNotifications()
method.
UNUserNotificationCenter.Current.Delegate = CrossFirebasePushNotification.Current as IUNUserNotificationCenterDelegate;
However, when you implement local notifications, the AppDelegate class must specify an iOSNotificationReceiver object as the UNUserNotificationCenter delegate during application startup , so you need add the following code
UNUserNotificationCenter.Current.Delegate = new iOSNotificationReceiver();
This is why you can't receive the notifications. If you still want to use this plugin, you have to define one delegate, and try to change the the source code of FirebasePushNotificationPlugin
. The key point is changing the WillPresentNotification
method and DidReceiveNotificationResponse
method in FirebasePushNotificationManager.ios.cs.
You could judge RemoteNotification
and LocalNotification
by UNNotificationTrigger
class, and add the LocalNotification
code to these two methods, such as the following code
void ProcessNotification(UNNotification notification)
{
string title = notification.Request.Content.Title;
string message = notification.Request.Content.Body;
DependencyService.Get<INotificationManager>().ReceiveNotification(title, message);
}
It's a little hard to be compatible, that is why I do not recommend using third parties. I still try to set two delegate, but it doesn't work. You can keep exploring, If there is anything update, feel free to let me know.
--------------update----------------
I find a similar issue , if you still want to use FirebasePushNotificationPlugin, you could try to customize or report it to FirebasePushNotificationPlugin third-party tool.
If you don't want to use the third party plugin, you could refer to https://learn.microsoft.com/en-us/xamarin/android/data-cloud/google-messaging/remote-notifications-with-fcm?tabs=windows
https://learn.microsoft.com/en-us/xamarin/ios/platform/user-notifications/deprecated/remote-notifications-in-ios
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.