Tracking Push Notification Taps

🚧

Before you begin, make sure you’ve completed these steps:

👍

By the end of this guide, you should see the following result:

The mobile push notification is sent from Maestra and displayed on your device. When the notification is tapped, a click event is recorded in Maestra customer profile.

To check that clicks are being detected, please use this guide.

1. Submitting push notification click counts

📘

Add a call to Mindbox.onPushClicked in the activities you specified earlier in onMessageReceived.
Call Mindbox.onPushClicked from both onNewIntent and onCreate callbacks.

import cloud.mindbox.mobile_sdk.*

class MainActivity : AppCompatActivity() {

    private fun processMindboxIntent(intent: Intent?) {
        // Add Push Notification Tap here
        intent?.let { Mindbox.onPushClicked(this, it) }
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        processMindboxIntent(intent)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        processMindboxIntent(intent)
        
        // ...
    }

    // ...
}

Mindbox.onPushClicked method returns true if the SDK identifies the intent and processes it properly. Otherwise, the method returns false.
You can use this to implement additional logic if needed.

2. App navigation

A click invokes the Activity you specified during notification rendering. To process any other data from a push notification, use the getUrlFromPushIntent and getPayloadFromPushIntent methods.

val pushUrl = Mindbox.getUrlFromPushIntent(intent)
val payload = Mindbox.getPayloadFromPushIntent(intent)

👍

Check your results:

The mobile push notification is sent from Maestra and displayed on your device. When the notification is tapped, a click event is recorded in Maestra customer profile.

To check that clicks are being detected, please use this guide.