CleverTap / clevertap-flutter

CleverTap Flutter SDK
Other
30 stars 42 forks source link

FCM token unsubscribed/mute on Android #216

Closed hillary-myhealthafrica closed 5 months ago

hillary-myhealthafrica commented 5 months ago

All FCM tokens from android indicated unsubscribed. Works well when test push is sent. I tried updating profile with 'MSG-push': true as below but nothing changes. var profile = { 'Name': '${user.firstName} ${user.lastName}', 'Identity': user.id, 'Email': user.email, 'Phone': user.phone, 'MSG-push': true, }; CleverTapPlugin.onUserLogin(profile);

It Works well with IOS. I use the sample implementation from the documentation. Attached are the screenshots. Screenshot from 2024-02-01 13-04-07

Screenshot from 2024-02-01 13-06-06

Anush-Shand commented 5 months ago

@hillary-myhealthafrica Thanks for bringing this up. This is the desired behaviour and explained in this document (search for DDND) https://developer.clevertap.com/docs/concepts-user-profiles#manually-updating-predefined-user-profile-properties

For your situation it looks the notification permission hasn't been granted from the settings (disabled by default for Android 13 and above devices) and hence the FCM channel shows unsubscribed. Granting this permission and relaunching the app should get rid of this

hillary-myhealthafrica commented 5 months ago

Hello, I forgot to mention it affects all android devices. Attached is android 9 with same issue. I also request user to allow notifications permission but even if it is allowed, the status remains the same.

Screenshot from 2024-02-02 09-42-35

Anush-Shand commented 5 months ago

@hillary-myhealthafrica . Could you please confirm if the notification is displayed once you send it using this disabled icon. This icon is controlled by the ddnd flag which is passed to the backend with every event. Please check the above mentioned document for more details

hillary-myhealthafrica commented 5 months ago

Yes i get the notification when i send. But the devices are not listed for campaignes

Anush-Shand commented 5 months ago

@hillary-myhealthafrica Could you please check the value of the ddnd flag set in the logs? If this value is passes as true then the channel shows unsubscribed on the dashboard

Screenshot 2024-02-02 at 1 15 27 PM
hillary-myhealthafrica commented 5 months ago

ct_pi":"Email,Identity","ddnd":true,"rtl":[] Device: Android 9. It seems ddnd is true always

Anush-Shand commented 5 months ago

@hillary-myhealthafrica Okayy. This is strange if the notification settings is enabled. Could you share the entire verbose logs once the app is relaunched?

hillary-myhealthafrica commented 5 months ago

Here are the logs

V/CleverTap:RK8-848-Z66Z:async_deviceID( 8134): CleverTapAPI instance = com.clevertap.android.sdk.CleverTapAPI@3a470be
V/CleverTap( 8134): PostAsyncSafely Task: createNotificationChannel starting on...pool-11-thread-1
D/CleverTapPlugin( 8134): registerForPush method is only applicable for iOS
I/CleverTap:RK8-848-Z66Z( 8134): Notification channel High Importance Notifications has been created
V/CleverTap( 8134): PostAsyncSafely Task: createNotificationChannel executed successfully on...pool-11-thread-1
V/CleverTap( 8134): PostAsyncSafely Task: initializeInbox starting on...pool-11-thread-1
V/CleverTap( 8134): PostAsyncSafely Task: initializeInbox executed successfully on...pool-11-thread-1
[log] _handleKilledStateNotificationInteraction => CleverTapAppLaunchNotification{didNotificationLaunchApp: false, payload: null}
I/flutter ( 8134): _platformCallHandler call inboxDidInitialize null
V/CleverTap:RK8-848-Z66Z( 8134):  [PushType:FCM] register device token eATl0qKjTPGIfAXLmJ6TWj:APA91bGh1SGb5h3iSQflV0U264Wl0GAtcts8Xlfj5jnVEMrKb4394uD7vnSbvYcc3K7EroMYzMkMle-rzRVeuardUAKMbORY2qApuavtsmsJkghvZ1y0ZSOoIYUqsS6px70xndahmrBH
[log] inboxDidInitialize called
V/CleverTap( 8134): PostAsyncSafely Task: queueEvent starting on...pool-11-thread-1
V/CleverTap:RK8-848-Z66Z( 8134): Local cache doesn't need to be updated
V/CleverTap( 8134): ioTask Task: PushProviders#cacheToken starting on...pool-10-thread-8
V/CleverTap:[:PushProvider:RK8-848-Z66Z]( 8134):  [PushType:FCM] getting Cached Token - eATl0qKjTPGIfAXLmJ6TWj:APA91bGh1SGb5h3iSQflV0U264Wl0GAtcts8Xlfj5jnVEMrKb4394uD7vnSbvYcc3K7EroMYzMkMle-rzRVeuardUAKMbORY2qApuavtsmsJkghvZ1y0ZSOoIYUqsS6px70xndahmrBH
V/CleverTap:[:PushProvider:RK8-848-Z66Z]( 8134):  [PushType:FCM] Token Already available value: true
V/CleverTap( 8134): ioTask Task: PushProviders#cacheToken executed successfully on...pool-10-thread-8
D/CleverTap:RK8-848-Z66Z( 8134): Queued event: {"data":{"action":"register","id":"eATl0qKjTPGIfAXLmJ6TWj:APA91bGh1SGb5h3iSQflV0U264Wl0GAtcts8Xlfj5jnVEMrKb4394uD7vnSbvYcc3K7EroMYzMkMle-rzRVeuardUAKMbORY2qApuavtsmsJkghvZ1y0ZSOoIYUqsS6px70xndahmrBH","type":"fcm"},"s":1706861991,"pg":1,"type":"data","ep":1706862294,"f":false,"lsl":-2833,"dsync":false}
V/CleverTap:RK8-848-Z66Z( 8134): Queued event to DB table EVENTS: {"data":{"action":"register","id":"eATl0qKjTPGIfAXLmJ6TWj:APA91bGh1SGb5h3iSQflV0U264Wl0GAtcts8Xlfj5jnVEMrKb4394uD7vnSbvYcc3K7EroMYzMkMle-rzRVeuardUAKMbORY2qApuavtsmsJkghvZ1y0ZSOoIYUqsS6px70xndahmrBH","type":"fcm"},"s":1706861991,"pg":1,"type":"data","ep":1706862294,"f":false,"lsl":-2833,"dsync":false}
D/CleverTap:RK8-848-Z66Z( 8134): Network retry #0
D/CleverTap:RK8-848-Z66Z( 8134): Failure count is 0. Setting delay frequency to 1s
V/CleverTap:RK8-848-Z66Z( 8134): Scheduling delayed queue flush on main event loop
V/CleverTap( 8134): PostAsyncSafely Task: queueEvent executed successfully on...pool-11-thread-1
V/CleverTap( 8134): PostAsyncSafely Task: CommsManager#flushQueueAsync starting on...pool-11-thread-1
V/CleverTap:RK8-848-Z66Z( 8134): Pushing event onto queue flush sync
V/CleverTap:RK8-848-Z66Z( 8134): Pushing Notification Viewed event onto queue DB flush
V/CleverTap:RK8-848-Z66Z( 8134): Somebody has invoked me to send the queue to CleverTap servers
V/CleverTap:RK8-848-Z66Z( 8134): Returning Queued events
V/CleverTap( 8134): ManifestInfo: getProxyDomain called, returning proxyDomain:null
V/CleverTap( 8134): ManifestInfo: getSpikeyProxyDomain called, returning spikeyProxyDomain:null
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): getCachedGUIDs:[{"Email_hillary@myhealthafrica.com":"__07b376e599c345599445d595c9a486c3","Identity_22618":"__07b376e599c345599445d595c9a486c3"}]
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): getCachedIdentityKeysForAccount:Email,Identity
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): isLegacyProfileLoggedIn:false
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): getCachedIdentityKeysForAccount:Email,Identity
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): ConfigurableIdentityRepoPrefIdentitySet [Email,Identity]
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): ConfigurableIdentityRepoConfigIdentitySet []
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): ConfigurableIdentityRepoNo error found while comparing [Pref:Email,Identity], [Config:]
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): ConfigurableIdentityRepoIdentity Set activated from Pref[Email,Identity]
V/CleverTap:[:ON_USER_LOGIN:RK8-848-Z66Z]( 8134): Repo provider: ConfigurableIdentityRepo
V/CleverTap:RK8-848-Z66Z( 8134): New ARP Key = ARP:RK8-848-Z66Z:__07b376e599c345599445d595c9a486c3
V/CleverTap:RK8-848-Z66Z( 8134): Fetched ARP for namespace key: ARP:RK8-848-Z66Z:__07b376e599c345599445d595c9a486c3 values: {sv=50201, dh=1690969244, wdt=2, d_ts=1706856990, hgt=5, av=1.5.5, v=2, e_ts=0, j_n=YmJiegEC, i_n=YmJieQYE, r_ts=1706862080, id=RK8-848-Z66Z, k_n=DHhgeQQBCRZ7eDoiOzYzOUtwXE0/PzMnIzIzLUBZUlV5OT0mdQc=, j_s={}}
V/CleverTap( 8134): Attaching InAppFC to Header
D/CleverTap:RK8-848-Z66Z( 8134): Send queue contains 1 items: [{"g":"__07b376e599c345599445d595c9a486c3","type":"meta","af":{"Build":"136","Version":"1.5.5","OS Version":"9","SDK Version":50201,"Make":"TECNO MOBILE LIMITED","Model":"TECNO CC7","Carrier":"Safaricom","useIP":false,"OS":"Android","wdt":2.67,"hgt":5.35,"dpi":320,"dt":1,"locale":"en_US","abckt":"active","lib":"Flutter","cc":"ke","LIAMC":0,"Flutter":20001},"id":"RK8-848-Z66Z","tk":"b4b-b32","l_ts":1706862079,"f_ts":1706856984,"ct_pi":"Email,Identity","ddnd":true,"rtl":[],"rct":0,"ait":0,"frs":false,"debug":true,"arp":{"sv":50201,"dh":1690969244,"wdt":2,"d_ts":1706856990,"hgt":5,"av":"1.5.5","v":2,"e_ts":0,"j_n":"YmJiegEC","i_n":"YmJieQYE","r_ts":1706862080,"id":"RK8-848-Z66Z","k_n":"DHhgeQQBCRZ7eDoiOzYzOUtwXE0\/PzMnIzIzLUBZUlV5OT0mdQc=","j_s":"{}"},"imp":0,"tlc":[]}, {"data":{"action":"register","id":"eATl0qKjTPGIfAXLmJ6TWj:APA91bGh1SGb5h3iSQflV0U264Wl0GAtcts8Xlfj5jnVEMrKb4394uD7vnSbvYcc3K7EroMYzMkMle-rzRVeuardUAKMbORY2qApuavtsmsJkghvZ1y0ZSOoIYUqsS6px70xndahmrBH","type":"fcm"},"s":1706861991,"pg":1,"type":"data","ep":1706862294,"f":false,"lsl":-2833,"dsync":false}]
D/CleverTap:RK8-848-Z66Z( 8134): Sending queue to: https://eu1.clevertap-prod.com/a1?os=Android&t=50201&z=RK8-848-Z66Z&ts=1706862295
I/y1health.healt( 8134): The ClassLoaderContext is a special shared library.
I/System.out( 8134): [OkHttp] sendRequest>>
I/System.out( 8134): [OkHttp] sendRequest<<
V/CleverTap( 8134): Getting domain from header - null
V/CleverTap:RK8-848-Z66Z( 8134): Trying to process response: {"arp":{"k_n":"DHhgeQQBCRZ7eDoiOzYzOUtwXE0/PzMnIzIzLUBZUlV5OT0mdQc=","j_n":"YmJiegEC","i_n":"YmJieQYE","d_ts":1706856990,"dh":1690969244,"v":2,"j_s":"{}","id":"RK8-848-Z66Z","e_ts":0,"r_ts":1706862297,"wdt":2.67,"hgt":5.35,"av":"1.5.5","sv":50201},"imc":1,"imp":10}
V/CleverTap:RK8-848-Z66Z( 8134): InApp: Processing response
V/CleverTap:RK8-848-Z66Z( 8134): InApp: Response JSON object doesn't contain the inapp key, failing
V/CleverTap:RK8-848-Z66Z( 8134): ARP doesn't contain the Discarded Events key
V/CleverTap:RK8-848-Z66Z( 8134): New ARP Key = ARP:RK8-848-Z66Z:__07b376e599c345599445d595c9a486c3
V/CleverTap:RK8-848-Z66Z( 8134): Stored ARP for namespace key: ARP:RK8-848-Z66Z:__07b376e599c345599445d595c9a486c3 values: {"k_n":"DHhgeQQBCRZ7eDoiOzYzOUtwXE0\/PzMnIzIzLUBZUlV5OT0mdQc=","j_n":"YmJiegEC","i_n":"YmJieQYE","d_ts":1706856990,"dh":1690969244,"v":2,"j_s":"{}","id":"RK8-848-Z66Z","e_ts":0,"r_ts":1706862297,"wdt":2.67,"hgt":5.35,"av":"1.5.5","sv":50201}
V/CleverTap:RK8-848-Z66Z( 8134): Inbox: Processing response
V/CleverTap:RK8-848-Z66Z( 8134): Inbox: Response JSON object doesn't contain the inbox key
D/CleverTap:variables( 8134): Processing Variable response...
D/CleverTap:variables( 8134): processResponse() called with: response = [{"arp":{"k_n":"DHhgeQQBCRZ7eDoiOzYzOUtwXE0\/PzMnIzIzLUBZUlV5OT0mdQc=","j_n":"YmJiegEC","i_n":"YmJieQYE","d_ts":1706856990,"dh":1690969244,"v":2,"j_s":"{}","id":"RK8-848-Z66Z","e_ts":0,"r_ts":1706862297,"wdt":2.67,"hgt":5.35,"av":"1.5.5","sv":50201},"imc":1,"imp":10}], stringBody = [{"arp":{"k_n":"DHhgeQQBCRZ7eDoiOzYzOUtwXE0/PzMnIzIzLUBZUlV5OT0mdQc=","j_n":"YmJiegEC","i_n":"YmJieQYE","d_ts":1706856990,"dh":1690969244,"v":2,"j_s":"{}","id":"RK8-848-Z66Z","e_ts":0,"r_ts":1706862297,"wdt":2.67,"hgt":5.35,"av":"1.5.5","sv":50201},"imc":1,"imp":10}], context = [com.clevertap.android.sdk.Application@7e995fe]
D/CleverTap:variables( 8134): JSON object doesn't contain the vars key
V/CleverTap:RK8-848-Z66Z( 8134): Processing Display Unit items...
V/CleverTap:RK8-848-Z66Z( 8134): DisplayUnit : JSON object doesn't contain the Display Units key
V/CleverTap:RK8-848-Z66Z( 8134): Processing Feature Flags response...
V/CleverTap:RK8-848-Z66Z( 8134): Feature Flag : JSON object doesn't contain the Feature Flags key
V/CleverTap:RK8-848-Z66Z( 8134): Processing Product Config response...
V/CleverTap:RK8-848-Z66Z( 8134): Product Config : JSON object doesn't contain the Product Config key
V/CleverTap:RK8-848-Z66Z( 8134): Processing GeoFences response...
V/CleverTap:RK8-848-Z66Z( 8134): Geofences : JSON object doesn't contain the Geofences key
I/CleverTapResponse( 8134): Done processing response!
D/CleverTap:RK8-848-Z66Z( 8134): Queue sent successfully
V/CleverTap:RK8-848-Z66Z( 8134): Returning Queued events
V/CleverTap:RK8-848-Z66Z( 8134): No events in the queue, failing
V/CleverTap( 8134): PostAsyncSafely Task: CommsManager#flushQueueAsync executed successfully on...pool-11-thread-1
V/CleverTap( 8134): PostAsyncSafely Task: CommsManager#flushQueueAsync starting on...pool-11-thread-1
V/CleverTap:RK8-848-Z66Z( 8134): Pushing Notification Viewed event onto queue flush sync
V/CleverTap:RK8-848-Z66Z( 8134): Pushing Notification Viewed event onto queue DB flush
V/CleverTap:RK8-848-Z66Z( 8134): Somebody has invoked me to send the queue to CleverTap servers
V/CleverTap:RK8-848-Z66Z( 8134): Returning Queued Notification Viewed events
V/CleverTap:RK8-848-Z66Z( 8134): No events in the queue, failing
V/CleverTap( 8134): PostAsyncSafely Task: CommsManager#flushQueueAsync executed successfully on...pool-11-thread-1
hillary-myhealthafrica commented 5 months ago

Also something to note in case it affects, we have firebase push notifications implemented Inside main()

 CleverTapPlugin.onKilledStateNotificationClicked(
        onKilledStateNotificationClickedHandler);
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
}
Anush-Shand commented 5 months ago

@hillary-myhealthafrica The last comment is unclear, could you please elaborate?

Also could you raise a support ticket and attach a debug APK of the app. This requires further investigation and raising a support ticket with the APK will help us fast track the process. The same can be done on this link -> https://help.clevertap.com/hc/en-us Please also attach the Github Issue link on the same for tracking

hillary-myhealthafrica commented 5 months ago

Okay noted. Will give feedback

hillary-myhealthafrica commented 5 months ago

I have managed to find where the issue is. For some reasons, when using classpath 'com.google.gms:google-services:4.4.0', push notifications permissions are always disabled. I changed it to classpath 'com.google.gms:google-services:4.3.8' and it worked

Anush-Shand commented 5 months ago

@hillary-myhealthafrica Thanks for pointing this out