Push Callbacks

Initializing Netmera SDK with Callbacks

When initializing Netmera, you can register different types of callbacks:

  1. In-App Message Callbacks (.nmInAppMessageActionCallbacks())

  2. Push Action Callbacks (.nmPushActionCallbacks())

  3. Web Widget Callbacks (.nmWebWidgetCallbacks())

  4. Push Presentation Callbacks (.nmPushPresentationCallbacks())

Step 1: Initialize Netmera SDK with Callbacks

During the initialization of Netmera, specify which callbacks your app should handle and include the callback lines during the initialization step (Step 5: Initialize Netmera SDK).

  • .nmInAppMessageActionCallbacks()

  • .nmPushActionCallbacks()

  • .nmWebWidgetCallbacks()

  • .nmPushPresentationCallbacks()

override fun onCreate() {
    super.onCreate()

    val configBuilder = NetmeraConfiguration.Builder()
        .apiKey(apiKey)
        .firebaseSenderId(PropertiesUtil.gcmSenderId)
        .huaweiSenderId(PropertiesUtil.hmsSenderId) // For Huawei services
        .logging(true) // Enables Netmera logs in Logcat
        .nmPushActionCallbacks(NGPushActionCallbacks()) // Push Action Callback
        .nmInAppMessageActionCallbacks(NGInAppMessageActionCallbacks()) // In-App Message Callback
        .nmWebWidgetCallbacks(NGWebWidgetCallbacks()) // Web Widget Callback
        .nmPushPresentationCallbacks(NMPushPresentationCallbacks()) // In-App Presentation Callback 
    Netmera.init(configBuilder.build(this))
}

Step 2: Implement a Receiver Class

  • Extend NetmeraPushBroadcastReceiver and override the necessary callback methods. Avoid using Toast messages in the production environment.

Push Action Calllback

In-App Action Calllback

  • To trigger an in-app callback, select the banner style in the Netmera control panel.

  • The pop-up style will not trigger the callback.

Widget Callback Methods

  • Implement the NMWebWidgetCallbacks interface and override the onDeeplinkTriggered() and onOpenUrlTriggered() methods.

circle-info

Netmera Panel Settings:

  • Select "Widget" Style: Ensure the widget is set to "Widget" style in the Netmera panel to trigger the callback.

  • Choosing "Manage App": If the action should be handled within the app, select "Manage App" when assigning an action in "Create New Widget." Without this, the SDK will handle it, but the callback won't trigger.

Manage App Chosen

Push Presentation Callbacks

Netmera SDK allows you to intercept and manage how web content is presented to the user. By using the NMPushPresentationCallbacks, you can decide whether to use Netmera's default WebView or launch your own custom UI.

Configuration

The callbacks are registered during the Netmera initialization process within the NetmeraConfiguration.Builder.

Example Implementation

In the following example, we check a local preference to decide whether to launch a custom WebViewPopupActivity or let the SDK handle the presentation.

Last updated

Was this helpful?