Skip to content

How to open application webView on message tap?

Alexander Boldyrev edited this page Oct 30, 2024 · 7 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.

Customize web view appearance

You can define your own custom theme for the webView in styles.xml and change action bar / toolbar and notification bar colors, colorPrimary and colorPrimaryDark respectively. Use IB_AppTheme.WebView name.

<resources>
    <style name="IB_AppTheme.WebView">
        <item name="colorPrimary">@color/colorPrimary</item> <!-- color of toolbar background -->
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <!-- color of status / notification bar -->
        <item name="colorControlNormal">@android:color/white</item> <!-- color of navigation icon in toolbar -->
        <item name="titleTextColor">@android:color/white</item> <!-- color of toolbar title text -->
    </style>
</resources>

Theme usage example you can find in our Firebase example application and Huawei example application, provided with SDK.

Notice:

From version 12.x onwards, HTTP is disabled by default for security reasons, see migration guide for more information.

Clone this wiki locally