Appboy / appboy-android-sdk

Public repo for the Braze Android SDK
https://www.braze.com
Other
152 stars 102 forks source link

[Bug]: Push notifications failing to display after updating from 17.0.0 to 19.0.0 #255

Closed mateot1 closed 1 year ago

mateot1 commented 1 year ago

Braze Android SDK Version

23.3.0, possibly as early as 18.0.0

Steps To Reproduce

We recently were made aware that our marketing push notifications have been broken for quite some time. In-app messages still work, so the integration is working enough that it is receiving push notifications and displaying those, but is failing when it comes to the system push notifications.

We are currently using the sdk via this wrapper, which could certainly be part of the issue, but in order to ensure messages are forwarded to the sdk and bypass mparticle's wrapper I've temporarily added a call to BrazeFirebaseMessagingService.handleBrazeRemoteMessage in our own FirebaseMessagingService and I've been able to debug the issue far enough to confirm that a push is received and the sdk is attempting to call notify with a notification, it just never is shown on the device.

Looking at the logs, the only thing I noticed that seems to be going wrong is that the notification channel id from the payload is not being used (the sdk says it is invalid even though we have created one with this id). However, even after creating a channel with the default id (com_appboy_default_notification_channel), it still does not display.

Expected Behavior

The sdk should display a system push notification, with the correct channel (the logs say no channel with id found, even though one does exist).

Actual Incorrect Behavior

No push notification is displayed

Verbose Logs

2023-01-20 14:43:24.407 24813-25038 Braze v23....shReceiver com.reverb.app.debug                 I  Received broadcast message. Message: Intent { act=firebase_messaging_service_routing_action (has extras) }
2023-01-20 14:43:24.407 24813-25038 Braze v23.3.0 .Braze    com.reverb.app.debug                 D  Applying any pending runtime configuration values
2023-01-20 14:43:24.408 24813-25038 Braze v23....shReceiver com.reverb.app.debug                 I  Push message payload received: Bundle[{a=Hello, thank you., p=0, t=Test Push, _ab=true, cid=dGVzdF90ZXN0X2RpPTYzY2FmY2VhNDFmYWFhYTNiZDUzZTUxNGFjNWM4ZGZk, ab_nc="Sales"}]
2023-01-20 14:43:24.408 24813-25038 Braze v23....shReceiver com.reverb.app.debug                 D  Received visible push notification
2023-01-20 14:43:24.408 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Message without notification id provided in the extras bundle received. Using a hash of the message: 1763475619
2023-01-20 14:43:24.409 24813-25038 Braze v23....shReceiver com.reverb.app.debug                 V  Creating notification with payload:

                                                                                                    IsPushStory = false
                                                                                                    IsInlineImagePush = false
                                                                                                    IsConversationalPush = false
                                                                                                    NotificationChannelId = "Sales"
                                                                                                    NotificationReceivedTimestampMillis = 1674247404408
                                                                                                    TitleText = Test Push
                                                                                                    ContentText = Hello, thank you.
                                                                                                    ActionButtons = []
                                                                                                    PushStoryPageIndex = 0
                                                                                                    PushStoryPages = []
                                                                                                    ConversationMessages = []
                                                                                                    ConversationPersonMap = {}
2023-01-20 14:43:24.409 24813-25038 Braze v23....ionFactory com.reverb.app.debug                 V  Using BrazeNotificationPayload: 
                                                                                                    IsPushStory = false
                                                                                                    IsInlineImagePush = false
                                                                                                    IsConversationalPush = false
                                                                                                    NotificationChannelId = "Sales"
                                                                                                    NotificationReceivedTimestampMillis = 1674247404408
                                                                                                    TitleText = Test Push
                                                                                                    ContentText = Hello, thank you.
                                                                                                    ActionButtons = []
                                                                                                    PushStoryPageIndex = 0
                                                                                                    PushStoryPages = []
                                                                                                    ConversationMessages = []
                                                                                                    ConversationPersonMap = {}
2023-01-20 14:43:24.409 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Notification channel from extras is invalid. No channel found with id: "Sales"
2023-01-20 14:43:24.409 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting title for notification
2023-01-20 14:43:24.410 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Unable to find the xml BOOLEAN configuration value with primary key 'com_braze_push_notification_html_rendering_enabled'.Using default value 'false'.
2023-01-20 14:43:24.410 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Using resources value for key: 'com_braze_push_notification_html_rendering_enabled' and value: 'false'
2023-01-20 14:43:24.410 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting content for notification
2023-01-20 14:43:24.410 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting ticker for notification
2023-01-20 14:43:24.412 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Using resources value for key: 'com_braze_push_small_notification_icon' and value: '2131230938'
2023-01-20 14:43:24.412 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting small icon for notification via resource id
2023-01-20 14:43:24.412 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting large icon for notification
2023-01-20 14:43:24.412 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Large icon bitmap url not present in extras. Attempting to use resource id instead.
2023-01-20 14:43:24.413 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Unable to find the xml DRAWABLE_IDENTIFIER configuration value with primary key 'com_braze_push_large_notification_icon'.Using default value '0'.
2023-01-20 14:43:24.413 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Using resources value for key: 'com_braze_push_large_notification_icon' and value: '0'
2023-01-20 14:43:24.413 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Large icon resource id not present for notification
2023-01-20 14:43:24.413 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Large icon not set for notification
2023-01-20 14:43:24.413 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Summary text not present. Not setting summary text for notification.
2023-01-20 14:43:24.413 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Setting priority for notification
2023-01-20 14:43:24.413 24813-25038 Braze v23....yleFactory com.reverb.app.debug                 D  Rendering push notification with BigTextStyle
2023-01-20 14:43:24.413 24813-25038 Braze v23....yleFactory com.reverb.app.debug                 D  Setting style for notification
2023-01-20 14:43:24.413 24813-25038 Braze v23....ctionUtils com.reverb.app.debug                 D  No action buttons present. Not adding notification actions
2023-01-20 14:43:24.413 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Using default accent color for notification
2023-01-20 14:43:24.414 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Unable to find the xml COLOR configuration value with primary key 'com_braze_default_notification_accent_color'.Using default value 'null'.
2023-01-20 14:43:24.414 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Using resources value for key: 'com_braze_default_notification_accent_color' and value: 'null'
2023-01-20 14:43:24.414 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Category not present in notification extras. Not setting category for notification.
2023-01-20 14:43:24.415 24813-25038 Braze v23....shReceiver com.reverb.app.debug                 D  Value of notificationManager.areNotificationsEnabled() = true
2023-01-20 14:43:24.416 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Sending push message received broadcast
2023-01-20 14:43:24.416 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 V  Sending original Appboy broadcast receiver intent for RECEIVED
2023-01-20 14:43:24.416 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 V  Sending push action intent: Intent { act=com.reverb.app.debug.intent.APPBOY_PUSH_RECEIVED }
2023-01-20 14:43:24.416 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 V  Sending Braze broadcast receiver intent for RECEIVED
2023-01-20 14:43:24.416 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 V  Sending push action intent: Intent { act=com.braze.push.intent.NOTIFICATION_RECEIVED pkg=com.reverb.app.debug }
2023-01-20 14:43:24.417 24813-25038 Braze v23.3.0 .z0       com.reverb.app.debug                 D  com.braze.events.BrazePushEvent fired: BrazePushEvent(eventType=NOTIFICATION_RECEIVED, notificationPayload=
                                                                                                    IsPushStory = false
                                                                                                    IsInlineImagePush = false
                                                                                                    IsConversationalPush = false
                                                                                                    NotificationChannelId = "Sales"
                                                                                                    NotificationReceivedTimestampMillis = 1674247404408
                                                                                                    TitleText = Test Push
                                                                                                    ContentText = Hello, thank you.
                                                                                                    ActionButtons = []
                                                                                                    PushStoryPageIndex = 0
                                                                                                    PushStoryPages = []
                                                                                                    ConversationMessages = []
                                                                                                    ConversationPersonMap = {})
2023-01-20 14:43:24.417 24813-25038 Braze v23.3.0 .z0       com.reverb.app.debug                 I  Event was published, but no subscribers were found. Saving event for later publishing to a matching subscriber. Event class: class com.braze.events.BrazePushEvent
2023-01-20 14:43:24.417 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Unable to find the xml BOOLEAN configuration value with primary key 'com_braze_push_wake_screen_for_notification_enabled'.Using default value 'true'.
2023-01-20 14:43:24.417 24813-25038 Braze v23....onProvider com.reverb.app.debug                 D  Using resources value for key: 'com_braze_push_wake_screen_for_notification_enabled' and value: 'true'
2023-01-20 14:43:24.418 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Notification channel from extras is invalid, no channel found with id: "Sales"
2023-01-20 14:43:24.418 24813-25038 Braze v23....ationUtils com.reverb.app.debug                 D  Waking screen for notification
2023-01-20 14:43:35.699 24813-24941 Braze v23.3.0 .Braze    com.reverb.app.debug                 I  Requesting immediate data flush to Braze.

Additional Information

In-app messages still work, but pushes have apparently been broken ever since we updated mparticle some months ago (5.35.1 to 5.38.2, which I believe corresponds to 17.0.0 to 19.0.0 of the braze sdk). I am hoping we can roll forward so I have been debugging with the latest version of mparticle which pulls in 23.3.0 of the sdk. I have been testing on a device running Android 13.

radixdev commented 1 year ago
  1. Have you followed https://www.braze.com/docs/developer_guide/platform_integration_guides/android/android_13/#android-13-braze-sdk ? Are push notifications enabled for the device?
  2. Can you share the device model you're using?
  3. Can you share verbose logs starting from the start of the application launch and ending right after you receive the notification?
  4. Can you share your entire merged AndroidManifest.xml file?
  5. I can't reproduce our SDK not finding/using the correct notification channel. Can you share how that notification channel was created? Is Sales the identifier of the channel or the name of it? The SDK requires the id.
mateot1 commented 1 year ago
  1. Yes, we request the runtime permission since targeting 13. We have a separate internal service for non-marketing pushes and these continue to work. Also, this issue is not sdk-level specific as far as I can tell, our mparticle logs seem to indicate no pushes have succeeded on any device since the update.
  2. Pixel 5a
  3. I'd rather not share some of the data in the logs in a public forum but I'll look into editing some for you next week.
  4. I'll also check this for sensitive information and see what I can give you next week.
  5. Yes Sales is the ID, not the name. We use a translatable string from the name that is slightly different.
radixdev commented 1 year ago

Can you email this to support@braze.com? We'd need unedited logs and more detailed implementation specifics which would be better handled securely as you pointed out. We need more steps to reproduce your issue.

mateot1 commented 1 year ago

@radixdev just sent. Got an automated message that it's a company holiday, so... hope you get it tomorrow!

mateot1 commented 1 year ago

following up on 5 re the channel creation:

Channels are created using NotificationManagerCompat.from(context) and calling createNotificationChannel(notificationChannel). Each channel is initialized with NotificationChannel(channelId, name, notificationImportance) where (as you noticed) channelId is for some reason a capitalized string, name is a translatable string, and notificationImportance is almost always NotificationManager.IMPORTANCE_DEFAULT except for one case where we use IMPORTANCE_HIGH. I am certain these were created before attempting to send the push from braze using one of the ids.

mateot1 commented 1 year ago

@radixdev apologies, I just realized my test device had do not disturb on! Notifications are displaying. The only bug on Braze's end is not recognizing the channel id when the string is capitalized — I tried just using lowercase "sales" and that seems to work. I'll continue to debug and open an issue with mparticle if it seems to be with their integration.

radixdev commented 1 year ago

Hello @mateot1 ,

Please re-open a new issue with clean reproduction steps on how to reproduce notification channels being case-sensitive. This is not an issue we're aware of and could potentially just be an issue with mParticle as you're pointing out.

Thanks, Julian

mateot1 commented 1 year ago

@radixdev the mparticle sdk doesn't create our channels and I was encountering the bug while bypassing mparticle for receiving and displaying pushes so seems unlikely that it has anything to do with it, but it's a much less serious bug so I'll reopen once we get to the root cause of the main issue.