For the complete documentation index, see llms.txt. This page is also available as Markdown.

Push Callbacks

Netmera SDK sends push, in-app message, and web widget events through callback interfaces. This article shows how to register each callback and handle its events.

All callback interfaces are in the com.netmera.callbacks package.

Interface
Setter
Events

NMPushActionCallbacks

Netmera.setPushActionCallbacks(...)

Push registration, receive, open, dismiss, button click, and carousel selection

NMInAppMessageActionCallbacks

Netmera.setInAppMessageActionCallbacks(...)

In-app message shown, opened, and dismissed

NMWebWidgetCallbacks

Netmera.setWebWidgetCallbacks(...)

Web widget shown, dismissed, deeplink, and URL actions

NMPushPresentationCallbacks

Netmera.setPushPresentationCallbacks(...)

Web view presentation requests

Register callbacks

Register only the callbacks your app needs. Register it in an Application, Activity, Fragment, or another class with the required context.

Each setter replaces the previous instance. Pass null to remove a callback.

class MyApplication : Application() {

    override fun onCreate() {
        super.onCreate()

        Netmera.setPushActionCallbacks(MyPushActionCallbacks())
        Netmera.setInAppMessageActionCallbacks(MyInAppMessageActionCallbacks())
        Netmera.setWebWidgetCallbacks(MyWebWidgetCallbacks())
        Netmera.setPushPresentationCallbacks(MyPushPresentationCallbacks(this))

        Netmera.init(NetmeraParams(apiKey = apiKey, providers = listOf(NMFCMProvider())))
    }
}
public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        Netmera.setPushActionCallbacks(new MyPushActionCallbacks());
        Netmera.setInAppMessageActionCallbacks(new MyInAppMessageActionCallbacks());
        Netmera.setWebWidgetCallbacks(new MyWebWidgetCallbacks());
        Netmera.setPushPresentationCallbacks(new MyPushPresentationCallbacks(this));

        Netmera.init(new NetmeraParams(apiKey, Collections.singletonList(new NMFCMProvider())));
    }
}

Scope a callback to a screen

Remove screen-scoped callbacks when the screen stops. This prevents the SDK from retaining a destroyed Activity or Fragment.

Avoid Toast messages and other UI side effects in production callbacks. Use them only while testing event delivery.

Implement a push action callback

NMPushActionCallbacks reports the push notification lifecycle. For non-Netmera messages, netmeraPushObject is null and bundle contains the raw payload.

Add the implementation

Register the callback:

Implement an in-app message callback

NMInAppMessageActionCallbacks reports when an in-app message is shown, opened, or dismissed.

Select the banner style in the Netmera Panel. The pop-up style does not trigger these callbacks.

Register the callback:

Implement a web widget callback

NMWebWidgetCallbacks reports when a web widget is shown or dismissed. It also passes deeplink and URL actions to your app.

Netmera Panel Settings:

  • Select the Widget style.

  • Select Manage App in Create New Widget for app-managed actions.

  • Otherwise, the SDK handles the action and does not call onDeeplinkTriggered or onOpenUrlTriggered.

Register the callback:

Implement a push presentation callback

NMPushPresentationCallbacks controls web content opened by a push. Use it to present web content in your own UI.

  • Return true from presentWebView(push) after your app starts presentation. The SDK then skips its default web view.

  • Return false to use the SDK's default web view.

  • Use closeWebView(push) to dismiss your custom UI after a close request.

For example, instant-show pushes return false below. The SDK presents them. Other pushes open WebViewPopupActivity.

Load the push content

The Activity you open from presentWebView() is responsible for loading the push content into its own WebView. In onCreate(), pass your WebView instance to Netmera.handleWebContent(webView) — the SDK loads the push's HTML content into it.

To display a widget when you only have its URL, use Netmera.displayWidget.

Register the callback:

After registration, the SDK delivers the selected events to your callback implementations.

Last updated

Was this helpful?