AppIntegration

public class AppIntegration

Application hooks required by Airship. If automaticSetupEnabled is enabled (enabled by default), Airship will automatically integrate these calls into the application by swizzling methods. If automaticSetupEnabled is disabled, the application must call through to every method provided by this class.

  • Must be called by the UIApplicationDelegate’s application:performFetchWithCompletionHandler:.

    Declaration

    Swift

    @MainActor
    public class func application(
        _ application: UIApplication,
        performFetchWithCompletionHandler completionHandler: @escaping (
            UIBackgroundFetchResult
        ) -> Void
    )

    Parameters

    application

    The application

    completionHandler

    The completion handler.

  • Must be called by the UIApplicationDelegate’s application:didRegisterForRemoteNotificationsWithDeviceToken:.

    Declaration

    Swift

    @MainActor
    public class func application(
        _ application: UIApplication,
        didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data
    )

    Parameters

    application

    The application

    deviceToken

    The device token.

  • Must be called by the UIApplicationDelegate’s application:didFailToRegisterForRemoteNotificationsWithError:.

    Declaration

    Swift

    @MainActor
    public class func application(
        _ application: UIApplication,
        didFailToRegisterForRemoteNotificationsWithError error: any Error
    )

    Parameters

    application

    The application

    error

    The error.

  • Must be called by the UIApplicationDelegate’s application:didReceiveRemoteNotification:fetchCompletionHandler:.

    Declaration

    Swift

    @MainActor
    public class func application(
        _ application: UIApplication,
        didReceiveRemoteNotification userInfo: [AnyHashable: Any]
    ) async -> UIBackgroundFetchResult

    Parameters

    application

    The application

    userInfo

    The remote notification.

    completionHandler

    The completion handler.

  • Must be called by the WKExtensionDelegate’s didRegisterForRemoteNotificationsWithDeviceToken:.

  • Must be called by the WKExtensionDelegate’s didFailToRegisterForRemoteNotificationsWithError:.

  • Must be called by the WKExtensionDelegate’s didReceiveRemoteNotification:fetchCompletionHandler:.

  • Must be called by the UNUserNotificationDelegate’s userNotificationCenter:willPresentNotification:withCompletionHandler.

    Declaration

    Swift

    @MainActor
    public class func userNotificationCenter(
        _ center: UNUserNotificationCenter,
        willPresent notification: UNNotification
    ) async -> UNNotificationPresentationOptions

    Parameters

    center

    The notification center.

    notification

    The notification.

  • Must be called by the UNUserNotificationDelegate’s userNotificationCenter:willPresentNotification:withCompletionHandler.

    Declaration

    Swift

    @MainActor
    public class func userNotificationCenter(
        _ center: UNUserNotificationCenter,
        willPresent notification: UNNotification,
        withCompletionHandler completionHandler: @escaping @Sendable (UNNotificationPresentationOptions) -> Void
    )

    Parameters

    center

    The notification center.

    notification

    The notification.

    completionHandler

    The completion handler.

  • Processes a user’s response to a notification.

    Warning

    ⚠️ Deprecated. This asynchronous method is deprecated and will be removed in a future release. It can cause critical application lifecycle issues due to changes in how Apple’s modern User Notification delegates operate.

    ### Lifecycle Issues Explained

    Apple’s modern async notification delegate methods execute on a background thread by default instead of a the main thread. This creates a race condition during app launch:

    1. Main Thread: Proceeds with the standard launch sequence, making the app’s UI active and visible.
    2. Background Thread: Runs this notification code. By the time it can switch back to the main thread, the app is often already active.

    This breaks the critical assumption that code for a “direct open” notification runs before the app is fully interactive. This can lead to incorrect direct open counts.

    ### Migration

    To fix this, you must migrate to the synchronous version of this method, which accepts and forwards a completionHandler. This guarantees your code runs on the main thread at the correct point in the lifecycle, before the app becomes active.

    • center: The notification center that delivered the notification.

    • response: The user’s response to the notification.

    Declaration

    Swift

    @available(*, deprecated, message: "Use the synchronous version with a completionHandler to avoid lifecycle issues.")
    @MainActor
    public class func userNotificationCenter(
        _ center: UNUserNotificationCenter,
        didReceive response: UNNotificationResponse
    ) async
  • Must be called by the UNUserNotificationDelegate’s userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler.

    Declaration

    Swift

    @MainActor
    public class func userNotificationCenter(
        _ center: UNUserNotificationCenter,
        didReceive response: UNNotificationResponse,
        withCompletionHandler completionHandler: @escaping @Sendable () -> Void
    )

    Parameters

    center

    The notification center.

    response

    The notification response.

    completionHandler

    The completion handler