You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
I configure setNotificationWillShowInForegroundHandler with a custom callback. When I send a notification from the OneSignal dashboard UI to my Android device, the callback does not get called. Once I open this notification, and then send another notification from the dashboard again, the custom callback does get called.
Environment
RN: 0.66.3
react-native-onesignal: 4.3.3
installed via npm
Sending a test notification from the OneSignal dashboard UI to an Android device.
Steps to Reproduce Issue:
Install the OneSignal SDK using npm into your project
Configure setNotificationWillShowInForegroundHandler to receive a custom callback
Send a test notification from the OneSignal dashboard UI to Android device while the app is in foreground
Notice the custom callback does not get called and that OneSignal thinks the app is in background
Open the notification on device
Send a 2nd test notification from the OneSignal dashboard UI to Android device while the app is in foreground
Notice that the custom callback does get called this time
Logcat for initial notification sent via OneSignal dashboard UI (notice that it thinks the "App is in background" but the app is actually in foreground):
2021-11-19 16:44:28.792 V/OneSignal: initWithContext called with: android.app.ReceiverRestrictedContext@85d0163
2021-11-19 16:44:28.792 V/OneSignal: Starting OneSignal initialization!
2021-11-19 16:44:28.792 V/OneSignal: No class found, not setting up OSRemoteNotificationReceivedHandler
2021-11-19 16:44:28.792 D/OneSignal: OneSignal SDK initialization already completed.
2021-11-19 16:44:28.796 D/OneSignal: OSNotificationWorkManager enqueueing notification work with notificationId: d36dd8d4-18a1-4fdf-bddd-87908d2857e6 and jsonPayload: {"google.delivered_priority":"normal","google.sent_time":1637358266593,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"d36dd8d4-18a1-4fdf-bddd-87908d2857e6\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaY","google.message_id":"0:1637358266620512%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}
2021-11-19 16:44:28.838 D/OneSignal: NotificationWorker running doWork with data: Data {json_payload : {"google.delivered_priority":"normal","google.sent_time":1637358266593,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"d36dd8d4-18a1-4fdf-bddd-87908d2857e6\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaY","google.message_id":"0:1637358266620512%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}, android_notif_id : 0, is_restoring : false, timestamp : 1637358268, }
2021-11-19 16:44:28.839 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@65fb38e
2021-11-19 16:44:28.839 D/OneSignal: Running startTimeout with timeout: 25000 and runnable: com.onesignal.OSNotificationReceivedEvent$1@65fb38e
2021-11-19 16:44:28.839 W/OneSignal: remoteNotificationReceivedHandler not setup, displaying normal OneSignal notification
2021-11-19 16:44:28.839 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@65fb38e
2021-11-19 16:44:28.839 D/OneSignal: Starting processJobForDisplay opened: false fromBackgroundLogic: true
2021-11-19 16:44:28.839 I/OneSignal: App is in background, show notification
2021-11-19 16:44:28.845 D/ReactNativeNotifs: New message from FCM: Bundle[{google.delivered_priority=normal, google.sent_time=1637358266593, google.ttl=259200, google.original_priority=normal, custom={"a":{},"i":"d36dd8d4-18a1-4fdf-bddd-87908d2857e6"}, pri=5, vis=1, from=184454251789, alert=Test message body, title=Testing fridaY, google.message_id=0:1637358266620512%2a4518d1f9fd7ecd, google.c.sender.id=184454251789}]
2021-11-19 16:44:28.859 D/OneSignal: Saving Notification job: OSNotificationGenerationJob{jsonPayload={"google.delivered_priority":"normal","google.sent_time":1637358266593,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"d36dd8d4-18a1-4fdf-bddd-87908d2857e6\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaY","google.message_id":"0:1637358266620512%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}, isRestoring=false, shownTimeStamp=1637358268, overriddenBodyFromExtender=null, overriddenTitleFromExtender=null, overriddenSound=null, overriddenFlags=null, orgFlags=null, orgSound=null, notification=OSNotification{notificationExtender=null, groupedNotifications=null, androidNotificationId=-1316389154, notificationId='d36dd8d4-18a1-4fdf-bddd-87908d2857e6', templateName='', templateId='', title='Testing fridaY', body='Test message body', additionalData={}, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='184454251789', backgroundImageLayout=null, collapseId='null', priority=5, rawPayload='{"google.delivered_priority":"normal","google.sent_time":1637358266593,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"d36dd8d4-18a1-4fdf-bddd-87908d2857e6\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaY","google.message_id":"0:1637358266620512%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}'}}
2021-11-19 16:44:28.866 D/OneSignal: Notification saved values: full_data={"google.delivered_priority":"normal","google.sent_time":1637358266593,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"d36dd8d4-18a1-4fdf-bddd-87908d2857e6\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaY","google.message_id":"0:1637358266620512%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"} notification_id=d36dd8d4-18a1-4fdf-bddd-87908d2857e6 android_notification_id=-1316389154 opened=0 expire_time=1637617466 title=Testing fridaY message=Test message body
2021-11-19 16:44:28.868 D/OneSignal: sendReceiveReceipt disabled
2021-11-19 16:44:28.868 D/OneSignal: OneSignal SessionManager onNotificationReceived notificationId: d36dd8d4-18a1-4fdf-bddd-87908d2857e6
2021-11-19 16:44:28.868 D/OneSignal: OneSignal OSChannelTracker for: notification_id saveLastId: d36dd8d4-18a1-4fdf-bddd-87908d2857e6
2021-11-19 16:44:28.868 D/OneSignal: OneSignal OSChannelTracker for: notification_id saveLastId with lastChannelObjectsReceived: [{"notification_id":"49ca41ae-802d-4a3a-b7a9-e196e9e57fbe","time":1637347351232},{"notification_id":"fb85293a-8395-4d35-829b-a795b4633320","time":1637348207300},{"notification_id":"eb090597-d21f-4e50-9d79-69bce69a40cc","time":1637349738850},{"notification_id":"0f267a26-2102-48da-9a06-d7726000aff1","time":1637350218653},{"notification_id":"8288551f-7792-4d5a-a0f2-3b0ef9dc5650","time":1637350687578},{"notification_id":"43ace525-9fd8-4ed2-aaae-7c5eba2414b0","time":1637351712096},{"notification_id":"890f326d-6139-4dbb-a314-f441b15cb98b","time":1637351915665},{"notification_id":"a3194d98-5f39-4343-9fde-6d48a8f03419","time":1637352275232},{"notification_id":"bc14b1a2-8bb1-4b68-be18-d21a052e0824","time":1637352430478},{"notification_id":"732d49db-2a35-48fd-a7f7-b00b16ab41ef","time":1637353017122}]
2021-11-19 16:44:28.868 D/OneSignal: OneSignal OSChannelTracker for: notification_id with channelObjectToSave: [{"notification_id":"fb85293a-8395-4d35-829b-a795b4633320","time":1637348207300},{"notification_id":"eb090597-d21f-4e50-9d79-69bce69a40cc","time":1637349738850},{"notification_id":"0f267a26-2102-48da-9a06-d7726000aff1","time":1637350218653},{"notification_id":"8288551f-7792-4d5a-a0f2-3b0ef9dc5650","time":1637350687578},{"notification_id":"43ace525-9fd8-4ed2-aaae-7c5eba2414b0","time":1637351712096},{"notification_id":"890f326d-6139-4dbb-a314-f441b15cb98b","time":1637351915665},{"notification_id":"a3194d98-5f39-4343-9fde-6d48a8f03419","time":1637352275232},{"notification_id":"bc14b1a2-8bb1-4b68-be18-d21a052e0824","time":1637352430478},{"notification_id":"732d49db-2a35-48fd-a7f7-b00b16ab41ef","time":1637353017122},{"notification_id":"d36dd8d4-18a1-4fdf-bddd-87908d2857e6","time":1637358268868}]
2021-11-19 16:44:28.870 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@3464fcb
2021-11-19 16:44:28.870 D/OneSignal: Running startTimeout with timeout: 5000 and runnable: com.onesignal.OSNotificationOpenedResult$1@3464fcb
2021-11-19 16:44:28.872 I/WM-WorkerWrapper: Worker result SUCCESS for Work [ id=767292e0-a28e-4bda-b6cb-b6199b98e2f3, tags={ com.onesignal.OSNotificationWorkManager$NotificationWorker } ]
2021-11-19 16:44:33.873 D/OneSignal: Running complete from OSNotificationOpenedResult timeout runnable!
2021-11-19 16:44:33.873 D/OneSignal: OSNotificationOpenedResult complete called with opened: false
2021-11-19 16:44:33.873 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@3464fcb
Logcat for 2nd notification sent from OneSignal dashboard UI:
2021-11-19 16:52:14.221 D/OneSignal: OSBackground sync, calling initWithContext
2021-11-19 16:52:14.222 V/OneSignal: initWithContext called with: com.onesignal.SyncJobService@e20312e
2021-11-19 16:52:14.222 V/OneSignal: Starting OneSignal initialization!
2021-11-19 16:52:14.222 V/OneSignal: No class found, not setting up OSRemoteNotificationReceivedHandler
2021-11-19 16:52:14.222 D/OneSignal: OneSignal SDK initialization already completed.
2021-11-19 16:52:14.225 D/OneSignal: LocationController sendAndClearPromptHandlers from non prompt flow
2021-11-19 16:52:14.227 D/OneSignal: LocationController startGetLocation with lastLocation: Location[fused 39.142385,-86.544974 hAcc=3.9 et=+4d1h1m39s335ms alt=210.22640818298166 vAcc=3.0 vel=0.07225275 sAcc=0.086023256 bear=328.31903 {Bundle[EMPTY_PARCEL]}]
2021-11-19 16:52:14.230 D/OneSignal: LocationController fireCompleteForLocation with location: Location[fused 39.142385,-86.544974 hAcc=3.9 et=+4d1h1m39s335ms alt=210.22640818298166 vAcc=3.0 vel=0.07225275 sAcc=0.086023256 bear=328.31903 {Bundle[EMPTY_PARCEL]}]
2021-11-19 16:52:14.230 D/OneSignal: LocationController scheduleUpdate lastTime: 0 minTime: 300000
2021-11-19 16:52:14.230 V/OneSignal: OSSyncService scheduleLocationUpdateTask:delayMs: 300000
2021-11-19 16:52:14.230 V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 300000
2021-11-19 16:52:14.231 V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob Scheduler already running!
2021-11-19 16:52:14.232 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: {"loc_acc":3.9,"loc_type":1,"lat":39.1423846,"long":-86.5449735,"loc_bg":false,"loc_time_stamp":1637358655000,"app_id":"619bb485-4121-436c-97e2-660b16a18edd"}
2021-11-19 16:52:14.236 D/OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a
2021-11-19 16:52:14.245 D/OneSignal: OneSignalRestClient: PUT SEND JSON: {"loc_acc":3.9,"loc_type":1,"lat":39.1423846,"long":-86.5449735,"loc_bg":false,"loc_time_stamp":1637358655000,"app_id":"619bb485-4121-436c-97e2-660b16a18edd"}
2021-11-19 16:52:14.550 V/OneSignal: OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a
2021-11-19 16:52:14.550 D/OneSignal: OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a
2021-11-19 16:52:14.558 D/OneSignal: OneSignalRestClient: PUT RECEIVED JSON: {"success":true}
2021-11-19 16:52:14.560 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: {"app_id":"619bb485-4121-436c-97e2-660b16a18edd","ad_id":"c6e47043-0b76-4ab9-93f0-ec5a06674bd6","device_os":"12","timezone":-18000,"language":"en","sdk":"040603","sdk_type":"react","android_package":"com.truckmap.truckmap.alpha","device_model":"Pixel 3","game_version":224,"net_type":0,"carrier":"Verizon","rooted":false,"timezone_id":"America\/New_York","loc_acc":3.9,"loc_type":1,"lat":39.1423846,"long":-86.5449735,"loc_bg":false,"loc_time_stamp":1637358655000}
2021-11-19 16:52:14.560 I/OneSignal: Error updating the user record because of the null user id
2021-11-19 16:52:14.560 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: {"app_id":"619bb485-4121-436c-97e2-660b16a18edd","device_os":"12","timezone":-18000,"timezone_id":"America\/New_York","language":"en","sdk":"040603","sdk_type":"react","android_package":"com.truckmap.truckmap.alpha","device_model":"Pixel 3","game_version":224,"net_type":0,"carrier":"Verizon","rooted":false,"loc_acc":3.9,"loc_type":1,"lat":39.1423846,"long":-86.5449735,"loc_bg":false,"loc_time_stamp":1637358655000}
2021-11-19 16:52:14.561 I/OneSignal: Error updating the user record because of the null user id
2021-11-19 16:52:14.561 D/OneSignal: LollipopSyncRunnable:JobFinished needsJobReschedule: true
2021-11-19 16:52:19.235 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: null
2021-11-19 16:52:20.551 V/OneSignal: initWithContext called with: android.app.ReceiverRestrictedContext@85d0163
2021-11-19 16:52:20.551 V/OneSignal: Starting OneSignal initialization!
2021-11-19 16:52:20.551 V/OneSignal: No class found, not setting up OSRemoteNotificationReceivedHandler
2021-11-19 16:52:20.551 D/OneSignal: OneSignal SDK initialization already completed.
2021-11-19 16:52:20.556 D/OneSignal: OSNotificationWorkManager enqueueing notification work with notificationId: 22907954-9457-46b4-a89a-dcf986cf3d92 and jsonPayload: {"google.delivered_priority":"normal","google.sent_time":1637358738386,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"22907954-9457-46b4-a89a-dcf986cf3d92\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaYy","google.message_id":"0:1637358738413357%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}
2021-11-19 16:52:20.573 D/ReactNativeNotifs: New message from FCM: Bundle[{google.delivered_priority=normal, google.sent_time=1637358738386, google.ttl=259200, google.original_priority=normal, custom={"a":{},"i":"22907954-9457-46b4-a89a-dcf986cf3d92"}, pri=5, vis=1, from=184454251789, alert=Test message body, title=Testing fridaYy, google.message_id=0:1637358738413357%2a4518d1f9fd7ecd, google.c.sender.id=184454251789}]
2021-11-19 16:52:20.599 D/OneSignal: NotificationWorker running doWork with data: Data {json_payload : {"google.delivered_priority":"normal","google.sent_time":1637358738386,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"22907954-9457-46b4-a89a-dcf986cf3d92\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaYy","google.message_id":"0:1637358738413357%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}, android_notif_id : 0, is_restoring : false, timestamp : 1637358740, }
2021-11-19 16:52:20.600 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@67fde8e
2021-11-19 16:52:20.600 D/OneSignal: Running startTimeout with timeout: 25000 and runnable: com.onesignal.OSNotificationReceivedEvent$1@67fde8e
2021-11-19 16:52:20.600 W/OneSignal: remoteNotificationReceivedHandler not setup, displaying normal OneSignal notification
2021-11-19 16:52:20.600 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@67fde8e
2021-11-19 16:52:20.600 D/OneSignal: Starting processJobForDisplay opened: false fromBackgroundLogic: true
2021-11-19 16:52:20.600 I/OneSignal: Fire notificationWillShowInForegroundHandler
2021-11-19 16:52:20.601 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@a1536af
2021-11-19 16:52:20.601 D/OneSignal: Running startTimeout with timeout: 25000 and runnable: com.onesignal.OSNotificationReceivedEvent$1@a1536af
2021-11-19 16:52:20.603 I/WM-WorkerWrapper: Worker result SUCCESS for Work [ id=0d79944c-80ad-40b1-92bb-3227fda1a3fb, tags={ com.onesignal.OSNotificationWorkManager$NotificationWorker } ]
2021-11-19 16:52:20.633 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@a1536af
2021-11-19 16:52:20.634 D/OneSignal: Saving Notification job: OSNotificationGenerationJob{jsonPayload={"google.delivered_priority":"normal","google.sent_time":1637358738386,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"22907954-9457-46b4-a89a-dcf986cf3d92\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaYy","google.message_id":"0:1637358738413357%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}, isRestoring=false, shownTimeStamp=1637358740, overriddenBodyFromExtender=null, overriddenTitleFromExtender=null, overriddenSound=null, overriddenFlags=null, orgFlags=null, orgSound=null, notification=OSNotification{notificationExtender=null, groupedNotifications=null, androidNotificationId=-1, notificationId='22907954-9457-46b4-a89a-dcf986cf3d92', templateName='', templateId='', title='Testing fridaYy', body='Test message body', additionalData={}, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='184454251789', backgroundImageLayout=null, collapseId='null', priority=5, rawPayload='{"google.delivered_priority":"normal","google.sent_time":1637358738386,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"22907954-9457-46b4-a89a-dcf986cf3d92\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaYy","google.message_id":"0:1637358738413357%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"}'}}
2021-11-19 16:52:20.639 D/OneSignal: Notification saved values: full_data={"google.delivered_priority":"normal","google.sent_time":1637358738386,"google.ttl":259200,"google.original_priority":"normal","custom":"{\"a\":{},\"i\":\"22907954-9457-46b4-a89a-dcf986cf3d92\"}","pri":"5","vis":"1","from":"184454251789","alert":"Test message body","title":"Testing fridaYy","google.message_id":"0:1637358738413357%2a4518d1f9fd7ecd","google.c.sender.id":"184454251789"} notification_id=22907954-9457-46b4-a89a-dcf986cf3d92 opened=1 expire_time=1637617938 title=Testing fridaYy message=Test message body
2021-11-19 16:52:20.639 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@232ca45
2021-11-19 16:52:20.639 D/OneSignal: Running startTimeout with timeout: 5000 and runnable: com.onesignal.OSNotificationOpenedResult$1@232ca45
2021-11-19 16:52:25.642 D/OneSignal: Running complete from OSNotificationOpenedResult timeout runnable!
2021-11-19 16:52:25.643 D/OneSignal: OSNotificationOpenedResult complete called with opened: false
2021-11-19 16:52:25.643 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@232ca45
The problem seems to point to the fact that on the initial notification send, OneSignal thinks the app is in background when its not. What can I do to make sure it knows the correct app state?
Is this possibly related to this issue?
Please let me know what other info I can provide. Thank you!
The text was updated successfully, but these errors were encountered:
I have the same problem. I constantly see this log: 10: 38: 35.390 27093 OneSignal App is in background, show notification
although my app is not found in background.
@AkeleyUA good to know! Once you open that first notification, does the 2nd notification trigger the correct behavior?
My assumption so far is that whatever initialization is happening upon opening a notification needs to happen before opening a notification.
Description:
I configure
setNotificationWillShowInForegroundHandler
with a custom callback. When I send a notification from the OneSignal dashboard UI to my Android device, the callback does not get called. Once I open this notification, and then send another notification from the dashboard again, the custom callback does get called.Environment
RN: 0.66.3
react-native-onesignal: 4.3.3
installed via npm
Sending a test notification from the OneSignal dashboard UI to an Android device.
Steps to Reproduce Issue:
setNotificationWillShowInForegroundHandler
to receive a custom callbackLogcat for initial notification sent via OneSignal dashboard UI (notice that it thinks the "App is in background" but the app is actually in foreground):
Logcat for opening a notification:
Logcat for 2nd notification sent from OneSignal dashboard UI:
The problem seems to point to the fact that on the initial notification send, OneSignal thinks the app is in background when its not. What can I do to make sure it knows the correct app state?
Is this possibly related to this issue?
Please let me know what other info I can provide. Thank you!
The text was updated successfully, but these errors were encountered: