-
Notifications
You must be signed in to change notification settings - Fork 21
In app messages
- Intro
- In-App messages
- Setup custom view controller for presenting in-app
- Handling tap on In-App messages
- Disable In-App messages
In-App messages are a type of communication tool with mobile users that includes banners, pop-ups and other formats that appear on screen of mobile applications while users are interacting with it. Read more documentation
Previously known as
Full-featured In-App notifications
.
Feature is available since 11.0.0 version.
In-App messages are disabled by default, and in order to enable them, you need to call .withFullFeaturedInApps()
method. Without enabling In-App messages MMNotificationMessageReceived
event is triggered, but In-App message is not processed and not displayed within WebView.
Enabling this feature also enables JavaScript execution on the webView for the feature proper work.
MobileMessaging
.withApplicationCode(<#your application code#>, notificationType: <#for example MMUserNotificationType(options: [.alert, .sound])#>)?
...
.withFullFeaturedInApps()
.start()
expand to see Objective-C code
[[[MobileMessaging withApplicationCode: <#your application code#> notificationType: <#your preferred MMUserNotificationType#>]
withFullFeaturedInApps]
start:nil];
After Mobile Messaging SDK is integrated into your app, you just need to create a Flow in Infobip Customer Portal, choose "Send In-App message" element and select "New messages", In-App message Editor will be opened, where you can create In-App message according to your preferences.
Banner | Pop-up | Fullscreen |
-
If you do not enable the feature, or use older versions of Mobile Messaging SDK, without this feature support,
MMNotificationMessageReceived
event will be triggered for this type of messages, but they won't be processed and displayed within WebView. -
For In-App messages,
MM_MTMessage
object in the parametertext
contains text "In-App", for the technical reasons, but this parameter won't be involved in the process of the displaying In-App messages
By default, In-App messages or web view, which opens by tapping In-App will be presented on the topmost visible view controller, but in case you have a complex UI hierarchy and the common solution doesn't fit, this behaviour could be changed.
-
Implement
MMMessageHandlingDelegate
protocol and it's methodinAppPresentingViewController(for message: MM_MTMessage) -> UIViewController?
, for example://Swift class MyMessageHandlingDelegate : MMMessageHandlingDelegate { func inAppPresentingViewController(for message: MM_MTMessage) -> UIViewController? { return UIApplication.shared.keyWindow?.rootViewController } }
expand to see Objective-C code
//Objective-C @interface MyMessageHandlingDelegate : NSObject <MMMessageHandlingDelegate> @end @implementation MyMessageHandlingDelegate - (UIViewController *)inAppPresentingViewControllerFor:(MM_MTMessage *)message { return UIApplication.sharedApplication.keyWindow.rootViewController; } @end
This method should return a view controller that would be used by MobileMessaging SDK as a presenting parent view controller for the In-App or In-App web view. UIApplication.shared.keyWindow?.rootViewController
in this example is the simplest general solution that fits many
simple iOS applications, however you should provide your own specific view controller, which fits your UI hierarchy.
-
Pass the custom MessageHandlingDelegate object to MobileMessaging SDK:
//Swift class MyMessageHandlingDelegate : MMMessageHandlingDelegate { ... }
//Swift MobileMessaging.messageHandlingDelegate = MyMessageHandlingDelegate()
expand to see Objective-C code
//Objective-C @interface MyMessageHandlingDelegate : NSObject <MMMessageHandlingDelegate> @end @implementation MyMessageHandlingDelegate @end
//Objective-C MobileMessaging.messageHandlingDelegate = [MyMessageHandlingDelegate new];
Following on-tap actions are supported for the Banner and for the action buttons of other In-App message types:
- Open URL in browser
- Open URL within the webView
- Open page in mobile app
More information can be found on the How to define specific action on notification or in-app primary button tap(open url, deeplink)?.
Additionally, MobileMessaging SDK will trigger:
-
MMNotificationMessageTapped
event if user tapped the banner In-App message -
MMNotificationActionTapped
event if user tapped action button of the Pop-up or Fullscreen notification - method
didPerform(action: MMNotificationAction, forMessage message: MM_MTMessage?, notificationUserInfo: [String: Any]?, completion: @escaping () -> Void)
of theMMMessageHandlingDelegate
(How to setup custom MessageHandlingDelegate)
It's possible to disable the Mirror push notification and In-App messages by specifying return value in the following method of custom MessageHandlingDelegate (How to setup custom MessageHandlingDelegate):
class MyMessageHandlingDelegate : MMMessageHandlingDelegate {
func shouldShowModalInAppNotification(for message: MM_MTMessage) -> Bool {
return false
}
}
expand to see Objective-C code
//Objective-C
@interface MyMessageHandlingDelegate : NSObject <MMMessageHandlingDelegate>
@end
@implementation MyMessageHandlingDelegate
- (BOOL)shouldShowModalInAppNotificationFor:(MM_MTMessage *)message {
return false;
}
@end
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
- Geofencing service
- Privacy settings
- In-app chat
- WebRTC Calls and UI