3.2. Android: Click counts on Mobile Push Notifications

🚧

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

👍

You've successfully completed the "Click Counts for Mobile Push Notifications on Android" step, if:

The push notification has been sent and is displayed on your phone. When clicked, its status in the system is changed to "click received".

To verify that clicks are being registered, follow this guide.

📘

1. Submitting push notification click counts

In the android/MainActivity.kt, add a call to the Mindbox.onPushClicked method.
Call this method in two callbacks: onNewIntent and onCreate.

package com.testmbsdk

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.facebook.react.ReactActivity
import cloud.mindbox.mobile_sdk.Mindbox

class MainActivity : ReactActivity() {
    private fun sendIntent(context: Context, intent: Intent) {
        Mindbox.onNewIntent(intent)
        Mindbox.onPushClicked(context, intent)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // ...
        intent?.let { sendIntent(this, it) }
    }

    override fun onNewIntent(intent: Intent) {
        super.onNewIntent(intent)
        // ...
        sendIntent(this, intent)
    }
}

The Mindbox.onPushClicked method returns true if the SDK successfully recognizes and processes the intent, and false otherwise.
Use this function if you need to implement additional logic.