CleverTap/clevertap-flutter

on clicking push notification the call back handler is not triggered

Closed this issue · 6 comments

I'm sending push notification from Clevertap Dashboard which is shown on the emulator, but on clicking the push notification nothing happens

using the Example code

clevertap_plugin: ^1.6.0

this is the console output

D/CleverTap:PushProvider( 5588):  [PushType:FCM] Found Valid Notification Message
V/CleverTap:[:PushProvider:W44-949-5Z6Z]( 5588):  [PushType:FCM] received notification from CleverTap: Bundle[{wzrk_acct_id=W44-949-5Z6Z, wzrk_pn_h=true, nm=New version app available, nt=Update, wzrk_pivot=wzrk_default, wzrk_cid=transactional, wzrk_rnv=false, wzrk_ttl=1679721591, nh_source=FcmMessageListenerService, wzrk_push_amp=false, wzrk_bc=, wzrk_bi=2, wzrk_ck=1635191617, wzrk_dt=FIREBASE, wzrk_id=0_0, wzrk_pn=true}]
V/CleverTap( 5588): PostAsyncSafely Task: CleverTapAPI#renderPushNotification starting on...pool-27-thread-1
D/CleverTap:W44-949-5Z6Z( 5588): Handling notification: Bundle[{wzrk_acct_id=W44-949-5Z6Z, wzrk_pn_h=true, nm=New version app available, nt=Update, wzrk_pivot=wzrk_default, wzrk_cid=transactional, wzrk_rnv=false, wzrk_ttl=1679721591, nh_source=FcmMessageListenerService, wzrk_push_amp=false, wzrk_bc=, wzrk_bi=2, wzrk_ck=1635191617, wzrk_dt=FIREBASE, wzrk_id=0_0, wzrk_pn=true}]
D/CleverTap:W44-949-5Z6Z( 5588): Handling notification::nh_source = FcmMessageListenerService
V/CleverTap:W44-949-5Z6Z( 5588): Converting collapse_key: 1635191617 to notificationId int: 1635191617
D/CleverTap:W44-949-5Z6Z( 5588): Creating the notification id: 1635191617 from collapse_key: 1635191617
W/System.err( 5588): java.lang.Exception: Logo is null
W/System.err( 5588): 	at com.clevertap.android.sdk.Utils.getAppIcon(Utils.java:637)
W/System.err( 5588): 	at com.clevertap.android.sdk.Utils.getNotificationBitmapWithSizeConstraints(Utils.java:414)
W/System.err( 5588): 	at com.clevertap.android.sdk.Utils.getNotificationBitmap(Utils.java:406)
W/System.err( 5588): 	at com.clevertap.android.sdk.pushnotification.CoreNotificationRenderer.renderNotification(CoreNotificationRenderer.java:109)
W/System.err( 5588): 	at com.clevertap.android.sdk.pushnotification.PushProviders.triggerNotification(PushProviders.java:1142)
W/System.err( 5588): 	at com.clevertap.android.sdk.pushnotification.PushProviders._createNotification(PushProviders.java:206)
W/System.err( 5588): 	at com.clevertap.android.sdk.CleverTapAPI$18.call(CleverTapAPI.java:2976)
W/System.err( 5588): 	at com.clevertap.android.sdk.CleverTapAPI$18.call(CleverTapAPI.java:2966)
W/System.err( 5588): 	at com.clevertap.android.sdk.task.Task$1.run(Task.java:234)
W/System.err( 5588): 	at com.clevertap.android.sdk.task.PostAsyncSafelyExecutor$1.run(PostAsyncSafelyExecutor.java:45)
W/System.err( 5588): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
W/System.err( 5588): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
W/System.err( 5588): 	at java.lang.Thread.run(Thread.java:1012)
D/CleverTap:W44-949-5Z6Z( 5588): Rendered notification: Notification(channel=transactional shortcut=null contentView=null vibrate=null sound=null defaults=0x0 flags=0x10 color=0x00000000 vis=PRIVATE)
V/CleverTap( 5588): Storing Push Notification...null - with ttl - 1679721591
D/CleverTap( 5588): Recording of Notification Viewed is disabled in the CleverTap Dashboard for notification payload: Bundle[{wzrk_acct_id=W44-949-5Z6Z, wzrk_pn_h=true, nm=New version app available, nt=Update, wzrk_pivot=wzrk_default, wzrk_cid=transactional, wzrk_rnv=false, wzrk_ttl=1679721591, nh_source=FcmMessageListenerService, wzrk_push_amp=false, wzrk_bc=, wzrk_bi=2, wzrk_ck=1635191617, wzrk_dt=FIREBASE, wzrk_id=0_0, wzrk_pn=true}]
V/CleverTap( 5588): PostAsyncSafely Task: CleverTapAPI#renderPushNotification executed successfully on...pool-27-thread-1
D/CleverTap:PushProvider( 5588):  [PushType:FCM] Found Valid Notification Message
V/CleverTap:[:PushProvider:W44-949-5Z6Z]( 5588):  [PushType:FCM] received notification from CleverTap: Bundle[{wzrk_acct_id=W44-949-5Z6Z, wzrk_pn_h=true, nm=New version app available, nt=Update, wzrk_pivot=wzrk_default, wzrk_cid=transactional, wzrk_rnv=false, wzrk_ttl=1679721591, nh_source=FcmMessageListenerService, wzrk_push_amp=false, wzrk_bc=, wzrk_bi=2, wzrk_ck=1635191817, wzrk_dt=FIREBASE, wzrk_id=0_0, wzrk_pn=true}]
V/CleverTap( 5588): PostAsyncSafely Task: CleverTapAPI#renderPushNotification starting on...pool-27-thread-1

Flutter doctor - v

[✓] Flutter (Channel stable, 3.7.7, on macOS 13.2.1 22D68 darwin-x64, locale en-GB)
    • Flutter version 3.7.7 on channel stable at /Users/incnut/Desktop/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2ad6cd72c0 (2 weeks ago), 2023-03-08 09:41:59 -0800
    • Engine revision 1837b5be5f
    • Dart version 2.19.4
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
    • Android SDK at /Users/incnut/Library/Android/sdk
    • Platform android-33, build-tools 34.0.0-rc1
    • ANDROID_HOME = /Users/incnut/Library/Android/sdk
    • Java binary at: /Applications/Android Studio 2.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14B47b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.76.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (3 available)
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
    • macOS (desktop)              • macos         • darwin-x64     • macOS 13.2.1 22D68 darwin-x64
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 111.0.5563.110

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Hi @rajeshzmoke

Thanks for reporting the issue. To start the investigation, please provide following details:

  • CleverTap Android SDK version(if you've added into the build.gradle)?
  • Android version of the Emulator device?
  • Setup and implementation for the push as per the CleverTap Push Doc?

CleverTap Android SDK version(if you've added into the build.gradle)?
app/build.gradle

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    implementation 'com.clevertap.android:clevertap-android-sdk:4.4.0'
    implementation 'com.google.firebase:firebase-messaging:21.0.0'
    implementation 'androidx.core:core:1.3.0'
    implementation 'androidx.fragment:fragment:1.3.6'

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.viewpager:viewpager:1.0.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.github.bumptech.glide:glide:4.12.0'

    implementation 'com.android.installreferrer:installreferrer:2.2'
}

build.gradle

dependencies {
     classpath 'com.android.tools.build:gradle:7.1.2'
     // START: FlutterFire Configuration
     classpath 'com.google.gms:google-services:4.3.10'
     classpath 'com.google.firebase:perf-plugin:1.4.1'
     classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
     // END: FlutterFire Configuration
     classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
 }

Android 13 on emulator device

setup is done asper docs

Hi @rajeshzmoke

Notification callback issue is expected if you have not catered the Notification trampolines handling for Android 12 and above.

Apps need to add the manual handling for android 12 onwards to raise the notification clicked event and get the corresponding clicked callback.

To achieve the same, add the following code in the onNewIntent() method of the Launcher FlutterActivity:

class MainActivity : FlutterActivity() {

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

   // On Android 12, Raise notification clicked event when Activity is already running in activity backstack
   if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
       cleverTapDefaultInstance?.pushNotificationClickedEvent(intent!!.extras)
        }
    }
}

The same is referred in the CleverTap Android Push doc.

thanks now it works, but need this info under Flutter sdk -> Push section in the documentation

thanks now it works, but need this info under Flutter sdk -> Push section in the documentation

@rajeshzmoke can u share your android code i am trying to integrate this flutter apk i am facing above error