MAUI: Push notification for iOS platform

I am using Plugin.Firebase and Plugin.Firebase.Crashlytics packages for implementing push notification in my MAUI application. I referred this blog and it was working fine on the Android platform. Now I am implementing it for the iOS platform.

I have done below set up on iOS platform:

  1. I have added Push Notification service into the app’s identifier on apple developer website.
  2. Created a new provisioning profile, install it on the device and bind it to the project settings.
  3. Created a new key.(.P8 file) and uploaded it into the FCM console. When uploading the key, provided the Team Id and Key Id.

Pending Set UP

  1. I need to enable the Remote Notification on Info.plist file. It was under Capabilities tab on Xamarin Forms application. But on MAUI there is no such tab.

enter image description here

  1. I need to enable the Push Notifications in the Entitlements.plist, but that file is not found on the MAUI iOS folder. Should I need to create it and How can I create such type of files?

After all these 2 pending set up, is FCM token will generate or anything else is pending to do on iOS platform?

Below is my FCM token function and it was working fine for Android platform:

private async void GetToken()
{
    await CrossFirebaseCloudMessaging.Current.CheckIfValidAsync();
    var token = await CrossFirebaseCloudMessaging.Current.GetTokenAsync();
    Preferences.Default.Set("devicefcmtoken", token);
    Console.WriteLine($"FCM token::>> {token}");
}

I need to enable the Remote Notification on Info.plist file. It was
under Capabilities tab on Xamarin Forms application. But on MAUI there
is no such tab.

You can manually edit the Info.plist by adding the following key/value pair to enable the Remote Notification:

<key>UIBackgroundModes</key>
    <array>
        <string>remote-notification</string>
    </array>

I need to enable the Push Notifications in the Entitlements.plist, but
that file is not found on the MAUI iOS folder. Should I need to create
it and How can I create such type of files?

To add a new entitlements file to your .NET MAUI app project, add a new XML file named Entitlements.plist to the Platforms\iOS folder of your app project. Then add the following XML to the file. And then add Push notifications to the Entitlements.plist. The entitlement is defined using the aps-environment key, of type String:


<?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>

For more information, see APS Environment Entitlement on developer.apple.com.

Leave a Comment