---
title: "iOS push notifications"
slug: "ios-push-notifications"
updated: 2026-06-25T15:11:16Z
published: 2026-06-25T15:11:16Z
canonical: "docs.xtremepush.com/ios-push-notifications"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xtremepush.com/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS push notifications

Configure push notifications within Xtremepush and your app

Push notifications for iOS require certificates generated from your Apple Developer account. Follow these steps to enable push notifications:

## Get Apple certificates

1. Log in to your Apple Developer account at ([https://developer.apple.com/membercenter/](https://developer.apple.com/membercenter/))
2. Select **Certificates, IDs and Profiles**
3. Select **Identifiers**

![196](https://cdn.document360.io/b056e88b-f6c1-4bd2-b5b8-08e9336a17c9/Images/Documentation/ae4ae43-Screenshot_2020-03-31_at_11.16.50(1).png)
4. Select the app you are integrating with Xtremepush and click **Edit**.
5. In **iOS App ID Settings**, click **Edit** next to **Push Notifications**.

![805](https://cdn.document360.io/b056e88b-f6c1-4bd2-b5b8-08e9336a17c9/Images/Documentation/c1a6154-Screenshot_2020-03-31_at_11.17.40(1).png)
6. Under **Development SSL Certificate** click "Create Certificate" and follow the step-by-step instructions to generate and download the certificate.

![679](https://cdn.document360.io/b056e88b-f6c1-4bd2-b5b8-08e9336a17c9/Images/Documentation/a700aa6-Screenshot_2020-03-31_at_11.18.08(1).png)
7. Repeat this procedure to generate and download a certificate under "Production SSL Certificate".
8. Open the certificates, which will show them in the Keychain Access application.
9. Select the certification and expand it to see the key below it.
10. Hold ⌘Cmd to select both the certificate and key and export them using **File > Export Items...**, choosing the (.p12) format.

## Configure Xtremepush

1. In Xtremepush, navigate to ****Settings > Apps & sites >** click on the matching iOS app **> Push > Push Settings**.
2. Upload the Production and Sandbox (development) certificates and press **Save**.

## Add to app

For basic testing, you can add the SDK's push notification `register` function to your `didFinishLaunchingWithOptions` method in your Application Delegate. For better user experience, the registration for push notifications should only be triggered after a prompt or *value-exchange* in your app, so your users know why push permissions are being requested and are more likely to agree to opt in. Learn more in our dedicated guide [here](/documentation/docs/ios-control-system-prompt).

> [!WARNING]
> **Xtremepush does not require you to set Delegate of UNUserNotificationCenter as it will conflict with our library.**

If you test using development builds then you should turn on *Sandbox Mode* as Apple uses a different gateway for builds compiled with a development mobile provisioning profile. If you only do enterprise builds you won't need this. Set sandbox mode in a statement that will only run for development builds as it should not be turned on in production.

Inside `didFinishLaunchingWithOptions` add the following:

**Swift**

```swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    XPush.setAppKey("XPUSH_APP_KEY")
    // Add registration for push notifications
    XPush.register(forRemoteNotificationTypes: [.alert, .badge, .sound]);
    // Set push notification sandbox mode only for development builds
    #if DEBUG
    XPush.setSandboxModeEnabled(true)
    #endif
    XPush.applicationDidFinishLaunching(options: launchOptions)
    return true
}
```

**Objective-C**

```objectivec
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [XPush setAppKey: @"XPUSH_APP_KEY"];
    // Add registration for push notifications
    [XPush registerForRemoteNotificationTypes:XPNotificationType_Alert | 
    XPNotificationType_Sound | XPNotificationType_Badge];
    // Set push notification sandbox mode only for development builds
    #if DEBUG     
    [XPush setSandboxModeEnabled:YES];     
    #endif 
    [XPush applicationDidFinishLaunchingWithOptions:launchOptions];
}
```

Add the the following iOS remote notifications handling methods in Application delegate, and place the corresponding Xtremepush method call in each of these as shown.

**Swift**

```swift
func application(_ application: UIApplication, 
    didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data){
    XPush.applicationDidRegisterForRemoteNotifications(withDeviceToken: deviceToken as Data!)
}
func application(_ application: UIApplication,
    didFailToRegisterForRemoteNotificationsWithError error: NSError) {
    XPush.applicationDidFailToRegisterForRemoteNotificationsWithError(error)
}
```

**Objective-C**

```objectivec
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [XPush applicationDidRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
    [XPush applicationDidFailToRegisterForRemoteNotificationsWithError:error];
}
```

## Using UNUserNotificationCenterDelegate with the XPush iOS SDK

Why this matters:

The XPush SDK relies on UNUserNotificationCenterDelegate callbacks to:

- track push opens/clicks
- handle foreground presentation behaviour
- process XPush-specific notification actions

> [!CAUTION]
> Important:
> 
> iOS only allows one UNUserNotificationCenter delegate. If your app sets its own delegate, XPush will no longer receive these callbacks unless you forward them.

Recommended approach:

If you need a custom delegate (e.g., to handle another push provider), you can still do so — just forward XPush notifications to the SDK.

1. Set the delegate Set your delegate once during app startup:

**Swift**

```swift
UNUserNotificationCenter.current().delegate
```

**Objective-C**

```objectivec
[UNUserNotificationCenter currentNotificationCenter].delegate = self;
```

1. Forward notifications to XPush in the delegate methods

**Swift**

```swift
import UserNotifications
import XPush

final class YourNotificationHandlerClass: NSObject, UNUserNotificationCenterDelegate {

    // Called when a notification is received while the app is in the foreground
    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        let userInfo = notification.request.content.userInfo
        if userInfo["xpush"] != nil {
            // Forward XPush notifications to the SDK
            XPush.userNotificationCenter(center, willPresent: notification, withCompletionHandler: completionHandler)
            return // SDK calls completionHandler
        }
        // Handle non-XPush notification actions here, if applicable
        completionHandler([.banner, .list, .sound])
    }

    // Called when the user taps a notification or interacts with an action button
    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {

        let userInfo = response.notification.request.content.userInfo
        if userInfo["xpush"] != nil {
            // Forward XPush notifications to the SDK
            XPush.userNotificationCenter(center, didReceive: response, withCompletionHandler: completionHandler)
            return // SDK calls completionHandler
        }
        // Handle non-XPush notification actions here, if applicable
        completionHandler()
    }
}
```

**Objective-C**

```objectivec
#import <UserNotifications/UserNotifications.h>
#import <XPush/XPush.h>
@interface YourNotificationHandlerClass () <UNUserNotificationCenterDelegate>
@end
@implementation YourNotificationHandlerClass
#pragma mark - UNUserNotificationCenterDelegate
// Called when a notification is received while the app is in the foreground
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
       willPresentNotification:(UNNotification *)notification
         withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
    NSDictionary *userInfo = notification.request.content.userInfo;
    if (userInfo[@"xpush"] != nil) {
        // Forward XPush notifications to the SDK
        [XPush userNotificationCenter:center
              willPresentNotification:notification
                withCompletionHandler:completionHandler];
        return; // SDK calls completionHandler
    }
    // Handle non-XPush notifications here (if applicable)
    completionHandler(UNNotificationPresentationOptionAlert);
}
// Called when the user taps a notification or interacts with an action button
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
         withCompletionHandler:(void (^)(void))completionHandler {
    NSDictionary *userInfo = response.notification.request.content.userInfo;
    if (userInfo[@"xpush"] != nil) {
        // Forward XPush notifications to the SDK
        [XPush userNotificationCenter:center
     didReceiveNotificationResponse:response
              withCompletionHandler:completionHandler];
        return; // SDK calls completionHandler
    }
    // Handle non-XPush notification actions here (if applicable)
    completionHandler();
}
@end
```

Notes:

- We check userInfo[@"xpush"] to route only XPush notifications to the SDK.
- Return immediately after calling XPush so you don't accidentally call completionHandler twice.
- If you support other providers, handle those in the else path.
