-
Notifications
You must be signed in to change notification settings - Fork 12
How to display messages when app is running in the foreground?
Mobile Messaging SDK has a built-in logic to display Mirror push notifications with a minimum development effort, more details here: Mirror push notifications
In order to display incoming messages (both pushed by APNs and pulled from the server) while your application is running in the foreground, you have to implement MMMessageHandlingDelegate protocol and its method willPresentInForeground(message:withCompletionHandler:). Then you have to pass the delegate object to the MobileMessaging SDK as shown below:
//AppDelegate.m
#import "AppDelegate.h"
#import "MainViewController.h"
+#import "<ApplicationName>-Swift.h"
+@import MobileMessaging;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions
{
self.viewController = [[MainViewController alloc] init];
+ MobileMessaging.messageHandlingDelegate = [CustomMessageHandlingDelegate new];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@endFor detailed examples of how to implement this CustomMessageHandlingDelegate refer to the iOS SDK documentation.
From the plugin version 7.2.1 onwards, a feature to always display Push notifications as Banner was introduced to Android SDK.
MobileMessaging.init({
applicationCode: '<YOUR_APP_CODE>',
android: {
withBannerForegroundNotificationsEnabled: true
}
})Using this parameter together with sending
MODALmirror in-app notifications will result in showing bothMODALandBANNERnotifications simultaneously.
If you have any questions or suggestions, feel free to send an email to [email protected] or create an issue.
- Library events
- Server errors
- Users and installations
- Messages and notifications management
- Inbox
GeofencingDEPRECATED- Privacy settings
- In-app chat
- Migration guides
- Migration guide to version 7.9.x
- Migration guide to version 7.x.x
- Migration guide to version 6.2.x
- Migration guide to version 6.1.x
- Migration guide to version 6.x.x
- Migration guide to version 1.x.x
- Migration guide to version 2.2.x
- Migration guide to version 3.x.x
- Migration guide to version 4.x.x
- Migration guide to version 4.1.x
- Troubleshooting
- JSON Web Token (JWT) structure and generation example
- Trusted Domains Security