Overview
Skill Level: Any
You can use notification controls in Mobile App Messaging to detect incoming mobile app messages. In iOS 10 (and later), you can cancel mobile app messages when the app is open. In this case, the incoming mobile app message is not displayed, which allows you to display your own mobile app message.
Step-by-step
-
To detect incoming mobile app messages, follow this step.
For iOS 10 (and later):
MCESdk.sharedInstance.presentNotification = ^BOOL(NSDictionary*){ NSLog(@"Checking if should present notification!"); // return FALSE if you don't want the notification to show to the user when the app is active return TRUE; };
For iOS 9 (and earlier):
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
Note that iOS only calls this method when the “content-available” flag is used in the push payload.
-
To cancel incoming mobile app messages when the app is open, follow this step.
For iOS 10 (and later):
Ensure that the method in Step 1 returns FALSE. If TRUE is returned, the incoming mobile app message is displayed.
For iOS 9 (and earlier):
You cannot cancel incoming mobile app messages.