Skip to content

How to open application webView on message tap

Alexander Boldyrev edited this page Oct 31, 2024 · 6 revisions

It's possible to provide URL, that will be opened on the webView, on notification tap or on Mirror push notification primary button tap automatically by MobileMessaging SDK.

To provide WebView URL via Broadcast or Flow choose "Mobile Push" channel and specify action button properties:

  • Action: "Open URL within webView"
  • WebView URL: "your URL"

Also, you can provide WebView URL for push or Mirror push notification using API by specifying notificationOptions.primaryButtonAction as follows:

"notificationOptions": {
    "primaryButtonAction": {
        "resource": "http://someurl.com",
        "type": "WEB_VIEW_URL"
    }
}

No additional coding is needed, but you could customize web view appearance or setup custom view controller for presenting web view

Customize web view appearance

If you need to customize the title, toolbar appearance or activity indicator, implement the following callback function in your custom MessageHandlingDelegate (How to set up custom MessageHandlingDelegate:

    class MyMessageHandlingDelegate : MMMessageHandlingDelegate {
        func inAppWebViewWillShowUp(_ webViewController: MMWebViewController, for message: MM_MTMessage) {
            webViewController.title = "Breaking news!" // to specify a custom title
            webViewController.barTintColor = UIColor.blue // to change the toolbar color
            webViewController.titleColor = UIColor.white // to change the toolbar title color
            webViewController.tintColor = UIColor.red // to change the toolbar button color 
            webViewController.activityIndicator = YourCustomActivityIndicator() // implement your own UIView subclass that conforms to ActivityIndicatorProtocol protocol to replace the standard activity indicator
        }
    }
Clone this wiki locally