Closed zamargab closed 11 months ago
Hi @zamargab
It seems you didn't define the cleverTapDefaultInstance
and also not imported required classes into the MainActivity
. To resolve this issue, please refer the following code:
import android.content.Intent
import android.os.Build
import com.clevertap.android.sdk.CleverTapAPI
import io.flutter.embedding.android.FlutterFragmentActivity
class MainActivity: FlutterFragmentActivity() {
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
// On Android 12 and above, inform the notification click to get the above mentioned callback on dart side.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val cleverTapDefaultInstance = CleverTapAPI.getDefaultInstance(this);
cleverTapDefaultInstance?.pushNotificationClickedEvent(intent.extras)
}
}
}
Closing this ticket for now. Feel free to reach out, if you need further assistance.
My implementation works on Android 11 and below but for android 12 and above, i cant seem to call pushClickedPayloadReceived when the notification is clicked when app is running in background to access notification payload. when app is killed, everything works fine.
I read the docs and was told to edit my MainActivity file, below is my code
I am getting error below. e: file:///Users/user/dev/peppa/android/app/src/main/kotlin/com/example/paysure/MainActivity.kt:13:38 Unresolved reference: Intent e: file:///Users/user/dev/peppa/android/app/src/main/kotlin/com/example/paysure/MainActivity.kt:17:13 Unresolved reference: Build e: file:///Users/user/dev/peppa/android/app/src/main/kotlin/com/example/paysure/MainActivity.kt:17:38 Unresolved reference: Build e: file:///Users/user/dev/peppa/android/app/src/main/kotlin/com/example/paysure/MainActivity.kt:18:13 Unresolved reference: cleverTapDefaultInstance