Skip to main content
Configure push notifications to receive, display, and handle Userpilot push notifications on iOS. The Userpilot SDK supports push notifications to help you deliver targeted messages and enhance user engagement.

Prerequisites

Configure your iOS push settings in the Userpilot Settings Studio before setting up push notifications in your app. To obtain the required keys and configuration details, refer to the iOS Push Notification Guide.

Setup

In Xcode, navigate to the Signing & Capabilities section of your main app target and add the Push Notifications capability. There are two options for configuring push notifications: automatic or manual. Automatic configuration is the quickest and simplest way to configure push notifications and is recommended for most customers.

Automatic Configuration

Automatic configuration takes advantage of swizzling to automatically provide the necessary implementations of the required UIApplicationDelegate and UNUserNotificationCenterDelegate methods. To enable automatic configuration, call Userpilot.enableAutomaticPushConfig() from UIApplicationDelegate.application(_:didFinishLaunchingWithOptions:).
Automatic configuration seamlessly integrates with your app’s existing push notification handling. It processes only Userpilot notifications, while ensuring that all other notifications continue to be handled by your app’s original logic.

Manual Configuration

Step 1. Register for Push Notifications
Step 2. Set Push Token for Userpilot To enable push notifications, your app must explicitly request permission from the user.
Call Userpilot.setPushToken(_:) from UIApplicationDelegate.application(_:didRegisterForRemoteNotificationsWithDeviceToken:) to pass the APNs token from calling registerForRemoteNotifications() to Userpilot.
Step 3. Enable Push Response Handling Update your AppDelegate to conform to the UNUserNotificationCenterDelegate protocol and assign self as the delegate in application(_:didFinishLaunchingWithOptions:). Implement userNotificationCenter(_:didReceive:withCompletionHandler:) and pass the received notification response to Userpilot.didReceiveNotification(response:completionHandler:).
Step 4. Configure Foreground Handling Configure handling of push notifications received while your app is in the foreground by implementing userNotificationCenter(_:willPresent:withCompletionHandler:).
For more details, refer to the AppDelegate+PushNotification.swift file in the sample app.