iOS SDK - Supporting Push Notifications

Supporting Re-engagement Tracking using Push Notifications

Singular enables push notification tracking to measure re-engagement for iOS apps. By integrating Apple Push Notification Service (APNs) and the Singular SDK, you can track user interactions with push notifications and attribute them accurately.

Follow the implementation guide below to ensure proper tracking of push notifications in your iOS application.

Why is Push Notification Tracking Important?

Push notifications are essential for user re-engagement, but without proper tracking, their impact is unclear. Singular ensures that notification interactions are properly attributed, allowing you to optimize marketing campaigns and measure user retention.

Implementation Guide

Step 1: Registering for Push Notifications

Ensure your app is properly registered for push notifications using UNUserNotificationCenter.

Examples:

SwiftObjective-C
import UserNotifications

// Set the current instance as the delegate for the UNUserNotificationCenter to handle notifications
UNUserNotificationCenter.current().delegate = self

// Define the notification authorization options (alert, badge, sound)
let pushAuthOptions: UNAuthorizationOptions = [.alert, .badge, .sound]

// Request notification authorization from the user
UNUserNotificationCenter.current().requestAuthorization(options: pushAuthOptions) { granted, error in
    // If an error occurs during authorization, print the error description
    if let error = error {
        print("registerForPushNotifications : failure - \(error.localizedDescription)")
    }
    
    // If the user granted permission for notifications, register for remote notifications
    if granted {
        // Ensure that the registration for remote notifications is done on the main thread
        DispatchQueue.main.async {
            UIApplication.shared.registerForRemoteNotifications()
        }
    }
}

This step ensures your app is set up to receive and handle push notifications.

Step 2: Handling Push Notifications and Passing Data to Singular

When a push notification is received, it must be processed and sent to Singular for tracking.

Examples:

SwiftObjective-C
func userNotificationCenter(_ center: UNUserNotificationCenter, 
                            didReceive response: UNNotificationResponse, 
                            withCompletionHandler completionHandler: @escaping () -> Void) {
    // Pass the notification data to Singular for tracking.
    Singular.handlePushNotification(response.notification.request.content.userInfo)
    
    // Call the completion handler to indicate processing is complete.
    completionHandler()
}

Step 3: Integrating Push Notification Payload with Singular SDK

Ensure the Singular SDK is correctly configured to handle push notifications.

Examples:

SwiftObjective-C
// Assuming config is an optional object, make sure it's not nil before using it
config?.pushNotificationLinkPath = [
    ["path", "to", "link"],["sng_link"]
]

// Start the Singular SDK with the given configuration (ensure config is valid)
Singular.start(config)

This step enables Singular to correctly track push notification interactions and attribute them accordingly.

Validation Guide

Step 4: Validating/Verifying Push Notification Receipt in the Start Session Call

The Singular SDK API call ensures that the push notification payload link is correctly passed under the singular_link reserved parameter in the start session call.

Example:

https://skan.singular.net:443/api/v1/start?dnt=-1&update_time=0&c=wwan&singular_link_resolve_required=false&rt=plist&lag=0.00&is=false&event_index=10&d=iPhone14,7&skan_has_framework=true&sdk=Singular/12.7.1&skan_conversion_value_mode=managed&mo=iPhone14,7&skan_update_counter=1&i=com.singular.SwiftScene&config_version=0&k=IDFV&cr=1&skan_total_admon_revenue_by_currency={}&install_time=1740577866&n=SwiftScene&av=1.0&skan_skadnetwork_enabled=true&p=iOS&idfv=D159BFDC-D061-479B-AB24-0CE00C1FA2AA&att_authorization_status=0&device_type=phone&s=F90C41BF-99EC-48FC-ABF8-2781FF5A2799&skan_first_call_to_skadnetwork_timestamp=1740577882&u=D159BFDC-D061-479B-AB24-0CE00C1FA2AA&skan_last_call_to_skadnetwork_timestamp=1740577882&singular_install_id=554DBBE4-9842-46A8-9F9D-24B8A9BF83E3&v=18.2.1&singular_link=https://sl.sng.link/Cclbu/2a7n_dl=com.singular.flutterApplication1&_smtype=3&singular_link_resolve_timeout=0&pu=1&a=sdk<>key&skan_total_revenue_by_currency={}&h=8aee646bc4b796a5f8908ef8af677ba0fde70aa9</>

Alternatively, you can use the Singular SDK Console to verify the push notification tracking link under the Deeplink URL, as demonstrated below.

By verifying this, you can confirm that push notification engagements are correctly tracked within the Singular SDK.

Notes:

  • Please note that, unlike the singularLinksHandler code, the Singular SDK does not provide push payload callbacks for this feature. It is the responsibility of the app developer to read the push notification data and implement the deep linking logic to redirect users to specific product pages within the app. In this solution, Singular retrieves the push notification payload when the user taps on the notification and includes this payload in the SDK start session event triggered by Singular.start(). This data is then processed on the Singular backend to attribute the push notification touchpoint/click and register it for re-engagement tracking.
  • We have a safety mechanism in place that allows only Singular link domains from the custom key value pair passed in the push notification payload. Specifically, only sng.link domains predefined in the Singular Manage Links page are permitted.

    For example:
    https://prod_test.sng.link/B0s2a/51oi?_dl=singular%3A%2F%2Fmain

    If you intend to wrap Singular links within a different domain (e.g., an ESP domain for email service providers), you must explicitly configure the domain by adding the following option in your setup: This ensures that the external domain is recognized and allowed within the Singular framework. please refer to the below configuration example. config.espDomains = @[@"sl.esp.link"];

  • If you need to trigger different deep links based on user actions from a single push notification, you can use a single Singular tracking link and dynamically modify redirects.

    Example:

    A push notification for breaking news may offer multiple deep link options:

    Instead of creating multiple tracking links, configure one Singular tracking link and adjust redirects dynamically based on user selection.

    Read Latest News
    newsapp://article?id=12345
    Trending Topics
    newsapp://trending
    Sports
    newsapp://sports

    Learn more about overriding redirects in Singular tracking links.

Success!

By following these steps, your iOS app is now configured to track push notifications using Singular. This improves engagement tracking, optimizes re-engagement campaigns, and enhances attribution accuracy.