LogoLogo
  • Home
  • Integration & SDKs
    • Web / Browser Push
      • Wordpress Integration Steps
      • Wix Integration Steps
      • Safari
        • Safari on Desktop
        • Safari on Mobile (iOS / iPadOS)
      • SDK
        • SDK Methods
        • SDK Events
        • Customizing Prompt CSS
        • AMP Support
        • E-Commerce / Abandoned Cart
    • Native App Push
      • Apple / iOS
        • P8 Key or P12 Cert Setup
        • SDK: Swift / Obj-C
          • Activity Tracking
          • Deep Linking
          • Live Activities
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Delegates
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • iOS SDK Changelog
      • Android
        • Firebase App Setup
        • SDK: Kotlin / Java
          • Deep Linking
          • Activity Tracking
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Callbacks
          • Live Activities
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • Android SDK Changelog
      • React Native
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: React Native
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
      • Flutter
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: Flutter
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
  • API
    • API Access Management
    • API Reference
  • Platform
    • Dashboard
    • Notifications
      • A/B Testing
      • Custom Buttons
      • Notification Previews
      • Inline Segmentation
      • Notification Templates
      • Macros
      • Native App Push Notifications
    • App Messages
    • Segments
      • Custom Geo Segmentation
    • Campaigns
    • Insights
    • User Management
    • Organizations
      • Multi-Factor Authentication
      • Single Sign On
        • Google Workspace
        • Microsoft Azure AD
        • Okta Workforce
      • Multi-Domain Notifications
      • Multi-Domain Segments
      • API Access
    • Multi-Channel Notifications
  • Info Center
    • Launch Guide & Best Practices
      • Landing Domain Whitelist
    • Web / Browser Push
      • Common Questions
      • Browser Support
      • Retrieve Push User ID
      • Not Getting Prompted
      • Not Receiving Notifications
      • How to Unsubscribe
    • Native App Push
      • Retrieve Push User ID
    • Workflow Planning
Powered by GitBook
On this page
  • SDK Lifecycle Delegates
  • Finished Loading
  • Permission Lifecycle Delegates
  • Permission Status Changed
  • Notification Lifecycle Delegates
  • Notification Received
  • Notification Opened With URI/URL Destination
  • App Message Lifecycle Delegates
  • App Message Will Present
  • App Message Received User Interaction
  1. Integration & SDKs
  2. Native App Push
  3. Apple / iOS
  4. SDK: Swift / Obj-C

SDK Delegates

We recommend including all SDK delegates within your application's AppDelegate class to ensure proper handling of all events.

SDK Lifecycle Delegates

These delegates can be implemented to observe SDK loading and exiting.

You must inform the SDK what class is going to implement this protocol. This can be done using the setSDKLifecycleDelegate method on the SDK:

PushSDK.setSDKLifecycleDelegate(self)
[PushSDK setSDKLifecycleDelegate:self];

The following SDK Lifecycle delegates are available:

Finished Loading

This delegate is called when the SDK finishes its initialization and is ready for interaction.

func pushSDK(didFinishLoading configuration: PNApplicationConfig, withNotificationSettings settings: UNNotificationSettings) {
    // Add code to execute after SDK finishes loading
}
- (void)pushSDKDidFinishLoading:(PNApplicationConfig *)configuration withNotificationSettings:(UNNotificationSettings *)settings {
    // Add code to execute after SDK finishes loading
}

Permission Lifecycle Delegates

These delegates can be implemented to observe a user's permission authorization changes.

You must inform the SDK what class is going to implement this protocol. This can be done using the setPermissionLifecycleDelegate method on the SDK:

PushSDK.setPermissionLifecycleDelegate(self)
[PushSDK setPermissionLifecycleDelegate:self];

The following Permission Lifecycle delegates are available:

Permission Status Changed

This delegate is called when a user's permission status/authorization has changed.

func pushSDK(didReceivePermissionStatusChange status: UNAuthorizationStatus, withSettings settings: UNNotificationSettings) {
    // Add code to execute after a user's notification permission has changed
}
- (void)pushSDKDidReceivePermissionStatusChange:(UNAuthorizationStatus)status withSettings:(UNNotificationSettings *)settings {
    // Add code to execute after a user's notification permission has changed
}

Notification Lifecycle Delegates

These delegates can be implemented to observe events like impressions, opens, and other interactions with notifications.

You must inform the SDK what class is going to implement this protocol. This can be done using the setNotificationLifecycleDelegate method on the SDK:

PushSDK.setNotificationLifecycleDelegate(self)
[PushSDK setPermissionLifecycleDelegate:self];

The following Notification Lifecycle delegates are available:

Notification Received

This delegate is called when a user receives a notification

func pushSDK(didReceiveNotification notification: PNNotification)
    // Add code to execute after the subscriber's device receives a notification
}
- (void)pushSDKDidReceiveNotification:(PNNotification *)notification {
    // Add code to execute after the subscriber's device receives a notification
}

Notification Opened With URI/URL Destination

This delegate is called when a notification is opened that has a landing URL attached. The subscriber should be navigated to the view that represents the URL.

This method expects a Boolean response. If the response is true then the SDK will perform no navigation action for this notification open. If the response is false then the SDK will attempt to navigate the subscriber to the destination URL by using the open method.

func pushSDK(didReceiveNotificationDestination destination: String, withInteraction interaction: PNNotificationInteraction) -> Bool {
    // Navigate to a view within your application using the destination (the Landing URL)
        
    // Return true to inform the SDK that it should not navigate
    return true
}
- (BOOL)pushSDKDidReceiveNotificationDestination:(NSString *)destination withInteraction:(PNNotificationInteraction *)interaction {
    // Redirect to a view within your application using the destination (the Landing URL)
    
    // Return YES to inform the SDK that it should not redirect
    return YES;
}

App Message Lifecycle Delegates

These delegates can be implemented to observe events like impressions, opens, and other interactions with app messages.

You must inform the SDK what class is going to implement this protocol. This can be done using the setAppMessageLifecycleDelegate method on the SDK:

PushSDK.setAppMessageLifecycleDelegate(self)
[PushSDK setAppMessageLifecycleDelegate:self];

The following App Message Lifecycle delegates are available:

App Message Will Present

This delegate is called when an App Message is presented to a user.

func pushSDK(willPresentAppMessage appMessage: PNAppMessage) {
    // Add code to execute when a user's device presents an app message
}
- (void)pushSDKWillPresentAppMessage:(PNAppMessage *)appMessage {
    // Add code to execute when a user's device presents an app message
}

App Message Received User Interaction

This delegate is called when a user interacts with an App Message.

This method expects a Boolean response. If the response is true then the SDK will not handle the interaction or attempt to perform navigation when the interaction is an Open URL action. If the response is false then the SDK will process the interaction and if the interaction is an Open URL action will attempt to navigate the user to the destination URL by using the open method.

func pushSDK(didReceiveAppMessageInteraction interaction: PNAppMessageInteraction, fromAppMessage appMessage: PNAppMessage) -> Bool {
    // Add code to execute when a user interacts with an app message
    
    // Return true to inform the SDK that it should not handle the interaction
    return true
}
- (BOOL)pushSDKDidReceiveAppMessageInteraction:(PNAppMessageInteraction *)interaction fromAppMessage:(PNAppMessage *)appMessage {
    // Add code to execute when a user interacts with an app message

    // Return YES to inform the SDK that it should not handle the interaction
    return YES;
}
PreviousSDK MethodsNextAdvanced

Last updated 1 year ago

The status variable represents the user's new permission status using the enum.

See the documentation for a complete example.

UNAuthorizationStatus
Deep Linking