Push messages

In order to use SDK built-in support for the Push Notifications, you need to configure your app to support Apple's Push Notifications, as you would normally do, and then you need to pass the deviceToken which your application has registered with a call to setPushToken in the SDK e.g:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSMutableString *token = [NSMutableString string];
    
    const char *data = [deviceToken bytes];
    for (NSUInteger i = 0; i < [deviceToken length]; i++) {
        [token appendFormat:@"%.2hhx", data[i]];
    }
  
    if (token) {
        [client setPushToken:token completion:^(CMPResult<NSNumber *> * result) {
            BOOL success = [result.object boolValue];
            if (result.error || !success) {
                // error occurred
            } else {
                // configuration successful
            }
        }];
    }
    
    // rest of you push notification code
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
    let token = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
    client.set(pushToken: token, completion: { (success, error) in
        if error != nil || !success {
                        // error
        } else {
                        // successfully configured push notifications
        }
    })
    
    // rest of you push notification code
}

Displaying push notifications when the app is in the foreground

Push notifications are displayed only while the app is in the background. These notification are sent to the notification center and launch your app when users tap them.

If you want to display the push notification message while the app is in the foreground or get access to the push notification to process the data, such as deep links, do one of the following, depending on the iOS version that your app is running on:

For iOS 9

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
    if (application.applicationState == UIApplicationStateActive) {
        
    }
}

For iOS 10 and above

- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
    
    completionHandler();
}