Push Notifications

Prev Next

Overview

Push Notifications in iOS allow you to send timely messages, promotions, or alerts directly to users, even when the app is not running. These notifications help engage and retain users by delivering relevant content at the right time.

Use Case

  1. Purpose:

    • Notify users about updates, reminders, or offers.

    • Drive engagement with direct access to specific app features or content.

  2. Benefits:

    • Maintain user interest and engagement with personalized content.

    • Boost app usage through targeted re-engagement strategies.

Implementation Details

  1. Enable/Disable Push Notifications: Dynamically enable or disable push notifications within the app.

    Appoxee.shared()?.disablePushNotifications(false, withCompletionHandler: { (error, data) in
        if error == nil {
            print("Push Notifications Enabled")
        }
    })
    
    Appoxee.shared()?.disablePushNotifications(true, withCompletionHandler: { (error, data) in
        if error == nil {
            print("Push Notifications Disabled")
        }
    })
    [[Appoxee shared] disablePushNotifications:NO withCompletionHandler:^(NSError * _Nullable error, id _Nullable data) {
        if (!error) {
            NSLog(@"Push Notifications Enabled");
        }
    }];
    
    [[Appoxee shared] disablePushNotifications:YES withCompletionHandler:^(NSError * _Nullable error, id _Nullable data) {
        if (!error) {
            NSLog(@"Push Notifications Disabled");
        }
    }];
  2. Check Push Notification State: Verify if push notifications are enabled or disabled.

    Appoxee.shared()?.isPushEnabled { (error, data) in
        if error == nil, let isEnabled = data as? Bool {
            print("Push Notifications Enabled: \(isEnabled)")
        }
    }
    [[Appoxee shared] isPushEnabled:^(NSError * _Nullable error, id _Nullable data) {
        if (!error) {
            BOOL isEnabled = [(NSNumber *)data boolValue];
            NSLog(@"Push Notifications Enabled: %d", isEnabled);
        }
    }];
  3. Postpone the Notification Permission Prompt: Set the postponeNotificationRequest property to true before calling engageAndAutoIntegrate* to delay the system permission dialog. The SDK then keeps quiet until you explicitly call showNotificationAlertDialog().

    Warning:

    Set postponeNotificationRequest before the SDK is engaged. Setting it after engageAndAutoIntegrate* has no effect — the permission dialog has already been requested.

    Appoxee.shared()?.postponeNotificationRequest = true
    Appoxee.shared.postponeNotificationRequest = YES;
  4. Show the Notification Alert Dialog: Trigger the system permission prompt at the moment of your choosing (typically after onboarding).

    Appoxee.shared()?.showNotificationAlertDialog()
    [[Appoxee shared] showNotificationAlertDialog];

Keep in mind:

  • For iOS 10 and above, ensure delegate methods are implemented for UNUserNotificationCenter.

  • Test notification functionality in all app states (foreground, background, and terminated).

  • Provide a clear and compelling reason for users to opt in to notifications.