Anyone implemented firebase push notification on maui .NET 8
I followed a tutorial and it worked well on android , I am able to receive the push notifications but on iOS it is not receiving the push notification.
I followed this tutorial
Below is my mauiprogram.cs
:
private static MauiAppBuilder RegisterFirebaseServices(this MauiAppBuilder builder)
{
builder.ConfigureLifecycleEvents(events =>
{
#if IOS
events.AddiOS(iOS => iOS.WillFinishLaunching((_, __) =>
{
CrossFirebase.Initialize();
FirebaseCloudMessagingImplementation.Initialize();
return false;
}));
#endif
#if ANDROID
events.AddAndroid(android => android.OnCreate((activity, _) =>
CrossFirebase.Initialize(activity)));
#endif
});
return builder;
}
I registered Firebase in maui like this:
.RegisterFirebaseServices()
Entitlement.plist :
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
</dict>
</plist>
Why doesn't it works on iOS? Do I need to specify any permission in info.plist
in order to receive push notification on iOS?
Has anyone implemented firebase push notification in maui .net 8 on iOS as well as Android?
As an answer to help others with similar question,
If you want to receive remote notification, you have to add "remote-notification" to the list of your Required background modes in your Info.plist. Try editing the info.plist to include the following code,
<key>UIBackgroundModes</key>
<array>
<string>remote-notification
</string>
</array>
For more info, please refer to UIBackgroundModes, GoogleApisForiOSComponents
Hope it helps!