GetStream / stream-chat-android

:speech_balloon: Android Chat SDK ➜ Stream Chat API. UI component libraries for chat apps. Kotlin & Jetpack Compose messaging SDK for Android chat
https://getstream.io/chat/sdk/android/
Other
1.44k stars 270 forks source link

Notification handler executed twice on tapping it #4217

Closed monil-shah-13 closed 1 year ago

monil-shah-13 commented 2 years ago

Describe the bug We have updated the stream library from 4.28.2 to 5.11.0. After updating, we are facing an issue where you click on the notification and it opens the activity mentioned in the getNotificationHandlerIntent twice. Due to this when user clicks back button, he will again see the same screen and will have to press the back button again in order to go to the previous screen.

We are using the custom notifications handler for our app. We have mentioned the details in this reply of a ticket we raised for other notification related issue.

SDK version

To Reproduce Steps to reproduce the behavior:

  1. Open the app.
  2. Send a message from other user to this user.
  3. Keep the app open and click on the notification
  4. See error

Expected behavior It should only call the notification handler once.

monil-shah-13 commented 2 years ago

Here are the error logs when tapping on notification

022-09-29 15:14:34.643 1076-3658/? E/ActivityTaskManager: activity starter requset gp list 
2022-09-29 15:14:34.643 1076-3658/? E/OplusAppStoreTraffic: InRegionList currentRegion = IN
2022-09-29 15:14:34.668 656-704/? E/BufferQueueProducer: [PopupWindow:b55cee6#0](id:29000000a74,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:34.979 1076-4931/? E/ActivityTaskManager: activity starter requset gp list 
2022-09-29 15:14:34.980 1076-4931/? E/OplusAppStoreTraffic: InRegionList currentRegion = IN
2022-09-29 15:14:35.197 656-3537/? E/BufferQueueProducer: [PopupWindow:ff89c78#0](id:29000000a78,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:35.700 656-656/? E/Layer: [Surface(name=ActivityRecord{2f4da85 u0 packageName/packageName.screens.MainActivity)/@0xb08decf - animation-leash#0] No local sync point found
2022-09-29 15:14:35.738 656-3537/? E/BufferQueueProducer: [NotificationShade#0](id:29000000a75,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:35.803 2506-2506/? E/PhoneInterfaceManager: [PhoneIntfMgr] getCarrierPackageNamesForIntentAndPhone: No UICC
2022-09-29 15:14:35.804 2506-2506/? E/PhoneInterfaceManager: [PhoneIntfMgr] getCarrierPackageNamesForIntentAndPhone: No UICC
2022-09-29 15:14:35.948 656-3537/? E/BufferQueueProducer: [packageName/packageName.screens.MainActivity#0](id:29000000a73,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:36.000 656-2903/? E/BufferQueueProducer: [PopupWindow:d546ee1#0](id:29000000a7a,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:37.176 1076-4665/? E/ActivityTaskManager: activity starter requset gp list 
2022-09-29 15:14:37.177 1076-4665/? E/OplusAppStoreTraffic: InRegionList currentRegion = IN
2022-09-29 15:14:37.190 1076-4665/? E/ActivityTaskManager: activity starter requset gp list 
2022-09-29 15:14:37.191 1076-4665/? E/OplusAppStoreTraffic: InRegionList currentRegion = IN
2022-09-29 15:14:37.272 656-704/? E/BufferQueueProducer: [PopupWindow:d546ee1#0](id:29000000a7a,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:37.582 656-2903/? E/BufferQueueProducer: [packageName/packageName.screens.MainActivity#1](id:29000000a76,api:0,p:-1,c:656) disconnect: not connected (req=1)
2022-09-29 15:14:37.658 1076-1136/? E/Watchdog: WDT_Monitor: checkSFStatus sfBlocked=false
2022-09-29 15:14:37.658 1076-1136/? E/Watchdog: WDT_Monitor: writeWDTMonitor duration=50,shutdowning=false
2022-09-29 15:14:38.238 656-3537/? E/BufferQueueProducer: [packageName/packageName.screens.MainActivity#2](id:29000000a79,api:0,p:-1,c:656) disconnect: not connected (req=1)
JcMinarro commented 1 year ago

Hello @monil-shah-13 The SDK use the native Notification implementation using the getNotificationHandlerIntent() as a PendingIntent, and it is started by the Android Operation System. It is executed once when you click on it. I have been reviewing the sample code you comment and the issue seems to be on the flags you are adding to the Intent. The FLAG_ACTIVITY_NEW_TASK flag will start this activity in a different task, what could cause multiple tasks in your Application. Could you try removing this flag from the Intent?

monil-shah-13 commented 1 year ago

Hi @JcMinarro,

Thanks for the response. This was helpful.

By removing FLAG_ACTIVITY_NEW_TASK flag the notification opens only once and that fixes the issue.

JcMinarro commented 1 year ago

Glad to hear it solves your problem. I'm closing this issue, feel free to open a new one if you need anything else.