You can use receivedNotification and openedNotification callback blocks to handle incoming notifications in iOS:
Objective-c
[Pushbots initWithAppId:@"APP_ID" withLaunchOptions:launchOptions prompt:true receivedNotification:^(NSDictionary *result) {
NSLog(@"receivedNotification: %@", result);
} openedNotification:^(NSDictionary *result) {
NSLog(@"openedNotification: %@", result);
}];
swift:
Pushbots.initWithAppId("PUSHBOTS_APPID", withLaunchOptions: launchOptions, prompt: true, receivedNotification:{(result) in
print(result)
}, openedNotification:{(result) in
print(result)
})
receivedNotification callback will be executed when the user receives a notification while the application is open/in foreground.
openedNotification callback will be executed when the user receives a notification while the application is open/in foreground and after clicking on a notification while app in background or killed.
To hide plugin prompt completely, you can use this code:
Pushbots.initWithAppId(pushBotsId, withLaunchOptions: launchOptions, prompt: false, receivedNotification: { dictionary in
self.handleReceivedPush(dictionary, state: UIApplication.shared.applicationState)
}, openedNotification: { dictionary in
self.handleOpenedPush(dictionary, state: UIApplication.shared.applicationState)
})