Introduction

Push notifications are a critical feature for modern mobile applications, providing real-time alerts,

updates, and improved user engagement. While Android uses Firebase Cloud Messaging (FCM), iOS

uses Apple Push Notification Service (APNS).

This article provides a complete, step-by-step guide to implementing APNS-based push notifications in

a .NET MAUI iOS application.

Overview of .NET MAUI

.NET MAUI (Multi-platform App UI) is a framework for building cross-platform, native applications using

C#. It supports:

  • iOS
  • Android
  • Windows
  • macOS
  • Single project structure
  • Native performance
  • Unified APIs

Push notification implementation is platform-specific. This article focuses only on iOS.

Prerequisites

Before starting, ensure you have:

  • macOS with Xcode installed
  • .NET 8 or later
  • Visual Studio 2022
  • An Apple Developer account (paid)
  • A physical iPhone (push notifications do NOT work on iOS simulators)
  • A .NET MAUI project
  • Apple Developer Certificates + App ID + Provisioning Profile

Step 1: Create App ID in Apple Developer Portal

  1. Go to https://developer.apple.com
  2. Navigate to Certificates, Identifiers & Profiles
  3. Select Identifiers → App IDs → +
  4. Choose App
  5. Enter:
  6. App Name
  7. Bundle ID (Example: com.companyname.myapp)
  8. Under Capabilities, enable:
  9. Push Notifications
  10. Save App ID

Step 2: Create Push Notification Key (APNS Key)

  1. In Apple Developer Portal → Certificates, Identifiers & Profiles
  2. Go to Keys → +
  3. Enter a name (e.g., "APNS-Key-MyApp")
  4. Enable Apple Push Notifications service (APNs)
  5. Download the generated key: AuthKey_XXXXX.p8
  6. Save the following:
  7. Key ID
  8. Team ID
  9. Bundle ID

You’ll need these for backend services like Azure Notification Hub or your custom server.

Step 3: Configure Entitlements in MAUI iOS Project

In your MAUI project, open:

Platforms/iOS/Entitlements.plist

Add:

HTML / XML
<dict>
<key>aps-environment</key>
<string>development</string> <!-- or production -->
</dict>

Use development while testing.

Step 4: Request Push Notification Permissions

In MauiProgram.cs, add:

C#
builder.Services.AddSingleton<IPushNotificationHandler,
PushNotificationHandler>();

In your app, call:

C#
await Permissions.RequestAsync<Permissions.Notification>();

Step 5: Implement iOS Push Notification Registration

Create or update AppDelegate.cs:

C#
using Foundation;
using UIKit;
using UserNotifications;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary
options)
{
UNUserNotificationCenter.Current.RequestAuthorization(
UNAuthorizationOptions.Alert |
UNAuthorizationOptions.Badge |
UNAuthorizationOptions.Sound,
(approved, err) => {});
UIApplication.SharedApplication.RegisterForRemoteNotifications();
return base.FinishedLaunching(app, options);
}
public override void RegisteredForRemoteNotifications(UIApplication
application, NSData deviceToken)
{
var token = deviceToken.Description;
token = token.Trim('<', '>').Replace(" ",
"");
Console.WriteLine($"APNS Device Token: {token}");
}
public override void
FailedToRegisterForRemoteNotifications(UIApplication application, NSError
error)
{
Console.WriteLine($"Failed to register:
{error.LocalizedDescription}");
}
}

This registers the device with APNS and retrieves the device token.

Step 6: Handle Incoming Notifications

In AppDelegate.cs, add:

C#
public override void DidReceiveRemoteNotification(UIApplication application,
NSDictionary userInfo,
Action<UIBackgroundFetchResult> completionHandler)
{
Console.WriteLine("Push received: " + userInfo);
completionHandler(UIBackgroundFetchResult.NewData);
}

Step 7: Send a Test Notification

You can send push notifications using:

Option 1: Azure Notification Hub

Use token + APNS key

Option 2: Postman (APNS HTTP/2 API)

POST →

Code
https://api.push.apple.com/3/device/{device_token}

Headers:

Code
authorization: bearer <JWT>
apns-topic: com.companyname.myapp

Body:

JSON
{
"aps": {
"alert": {
"title": "Hello iOS",
"body": "This is a test push notification"
},
"sound": "default"
}
}

Step 8: Important Notes for iOS

  • Push notifications do not work on iOS simulators
  • You must install the app on an actual device
  • Proper provisioning profiles are required
  • Use correct aps-environment in Entitlements.plist
  • Token changes on reinstall; always update it in your backend

Best Practices

  • Handle token refresh properly
  • Store tokens securely in your backend
  • Use silent notifications for background updates
  • Follow Apple's UX guidelines for notifications
  • Test both development & production environments

Conclusion

Implementing push notifications in .NET MAUI for iOS requires proper configuration of Apple Developer

settings, entitlements, device registration, and handling incoming APNS messages.

Once configured correctly, you can send real-time notifications to your iOS users using APNS, Azure

Notification Hubs, or your own backend.

This detailed guide should help you confidently integrate iOS push notifications into your .NET MAUI

application.