Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setNotificationWillShowInForegroundHandler callback not called until after opening a notification #1324

Closed
sweatherall opened this issue Nov 19, 2021 · 6 comments
Assignees

Comments

@sweatherall
Copy link

sweatherall commented Nov 19, 2021

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:

  1. Install the OneSignal SDK using npm into your project
  2. Configure setNotificationWillShowInForegroundHandler to receive a custom callback
  3. Send a test notification from the OneSignal dashboard UI to Android device while the app is in foreground
  4. Notice the custom callback does not get called and that OneSignal thinks the app is in background
  5. Open the notification on device
  6. Send a 2nd test notification from the OneSignal dashboard UI to Android device while the app is in foreground
  7. 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 opening a notification:

2021-11-19 16:46:53.365 D/OneSignal: onActivityPaused: com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.365 D/OneSignal: curActivity is NOW: null
2021-11-19 16:46:53.368 D/ReactNativeNotifs: onHostPause
2021-11-19 16:46:53.368 D/ReactNativeNotifs: App is now not visible
2021-11-19 16:46:53.369 D/OneSignal: onActivityResumed: com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.369 D/OneSignal: curActivity is NOW: com.truckmap.truckmap.MainActivity:com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.369 D/OneSignal: ActivityLifecycleHandler handleFocus, with runnable: null nextResumeIsFirstActivity: true
2021-11-19 16:46:53.369 D/OneSignal: ActivityLifecycleHandler reset background state, call app focus
2021-11-19 16:46:53.369 D/OneSignal: Application on focus
2021-11-19 16:46:53.373 D/OneSignal: GMSLocationController onFocusChange!
2021-11-19 16:46:53.384 D/OneSignal: GMSLocationController GoogleApiClient requestLocationUpdates!
2021-11-19 16:46:53.389 D/OneSignal: Application foregrounded focus time: 349055719
2021-11-19 16:46:53.389 D/OneSignal: isPastOnSessionTime currentTimeMillis: 1637358413389 lastSessionTime: 1637354305347 difference: 4108042
2021-11-19 16:46:53.389 D/OneSignal: Starting new session with appEntryState: APP_OPEN
2021-11-19 16:46:53.390 D/OneSignal: OneSignal cleanOutcomes for session
2021-11-19 16:46:53.391 D/OneSignal: OneSignal save unattributedUniqueOutcomeEvents: []
2021-11-19 16:46:53.391 D/OneSignal: OneSignal SessionManager restartSessionIfNeeded with entryAction: APP_OPEN
     channelTrackers: [OSChannelTracker{tag=notification_id, influenceType=INDIRECT, indirectIds=[], directId=null}, OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
2021-11-19 16:46:53.391 D/OneSignal: OneSignal ChannelTracker getLastReceivedIds lastChannelObjectReceived: [{"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:46:53.391 D/OneSignal: OneSignal SessionManager restartSessionIfNeeded lastIds: ["d36dd8d4-18a1-4fdf-bddd-87908d2857e6"]
2021-11-19 16:46:53.391 D/OneSignal: OneSignal ChannelTracker getLastReceivedIds lastChannelObjectReceived: []
2021-11-19 16:46:53.392 D/OneSignal: OneSignal SessionManager restartSessionIfNeeded lastIds: []
2021-11-19 16:46:53.392 D/OneSignal: OneSignal SessionManager sendSessionEndingWithInfluences with influences: []
2021-11-19 16:46:53.392 D/OneSignal: Last session time set to: 1637358413392
2021-11-19 16:46:53.392 D/OneSignal: initWithCachedInAppMessages: null
2021-11-19 16:46:53.393 D/OneSignal: LocationController sendAndClearPromptHandlers from non prompt flow
2021-11-19 16:46:53.394 D/OneSignal: LocationController startGetLocation with lastLocation: Location[fused 39.142577,-86.545103 hAcc=33.431 et=+4d0h54m7s933ms alt=209.9800518526943 vAcc=3.0 {Bundle[EMPTY_PARCEL]}]
2021-11-19 16:46:53.395 D/OneSignal: LocationController fireCompleteForLocation with location: Location[fused 39.142577,-86.545103 hAcc=33.431 et=+4d0h54m7s933ms alt=209.9800518526943 vAcc=3.0 {Bundle[EMPTY_PARCEL]}]
2021-11-19 16:46:53.396 D/OneSignal: registerUser:registerForPushFired:true, locationFired: true, remoteParams: com.onesignal.OneSignalRemoteParams$2@7ca8a07, appId: 619bb485-4121-436c-97e2-660b16a18edd
2021-11-19 16:46:53.396 D/OneSignal: LocationController scheduleUpdate lastTime: 0 minTime: 300000
2021-11-19 16:46:53.396 V/OneSignal: OSSyncService scheduleLocationUpdateTask:delayMs: 300000
2021-11-19 16:46:53.396 V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 300000
2021-11-19 16:46:53.399 I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
2021-11-19 16:46:53.400 D/OneSignal: LocationController scheduleUpdate lastTime: 4 minTime: 300000
2021-11-19 16:46:53.400 V/OneSignal: OSSyncService scheduleLocationUpdateTask:delayMs: 299996
2021-11-19 16:46:53.400 V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 299996
2021-11-19 16:46:53.402 D/OneSignal: registerUser:registerForPushFired:true, locationFired: true, remoteParams: com.onesignal.OneSignalRemoteParams$2@7ca8a07, appId: 619bb485-4121-436c-97e2-660b16a18edd
2021-11-19 16:46:53.403 I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
2021-11-19 16:46:53.405 D/OneSignal: registerUserTask calling readyToUpdate
2021-11-19 16:46:53.409 D/OneSignal: registerUserTask calling readyToUpdate
2021-11-19 16:46:53.414 D/ReactNativeNotifs: onHostResume
2021-11-19 16:46:53.414 D/ReactNativeNotifs: App is now visible
2021-11-19 16:46:53.414 E/OneSignal: Already initialized the OneSignal React-Native SDK
2021-11-19 16:46:53.415 I/ReactNativeJS: 'Calling', 'mapAppStateBackground'
2021-11-19 16:46:53.419 D/OneSignal: onActivityPaused: com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.419 D/OneSignal: ActivityLifecycleHandler Handling lost focus
2021-11-19 16:46:53.419 D/OneSignal: Application stopped focus time: 349055719 timeElapsed: null
2021-11-19 16:46:53.420 V/OneSignal: OSFocusDelaySync scheduleSyncTask:SYNC_AFTER_BG_DELAY_MS: 2000
2021-11-19 16:46:53.420 V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 2000
2021-11-19 16:46:53.422 I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
2021-11-19 16:46:53.422 D/OneSignal: curActivity is NOW: null
2021-11-19 16:46:53.424 I/ReactNativeJS: 'Calling', 'nativeAppStateBackground'
2021-11-19 16:46:53.424 D/ReactNativeNotifs: onHostPause
2021-11-19 16:46:53.424 D/ReactNativeNotifs: App is now not visible
2021-11-19 16:46:53.440 D/OneSignal: GMSLocationController onLocationChanged: Location[fused 39.142435,-86.545001 hAcc=4.288 et=+4d0h57m35s336ms alt=210.1381750443794 vAcc=3.0 vel=0.15678062 sAcc=0.13453624 bear=339.03323 {Bundle[EMPTY_PARCEL]}]
2021-11-19 16:46:53.450 V/OneSignal: initWithContext called with: com.truckmap.truckmap.MainApplication@b466a13
2021-11-19 16:46:53.450 V/OneSignal: Starting OneSignal initialization!
2021-11-19 16:46:53.451 V/OneSignal: No class found, not setting up OSRemoteNotificationReceivedHandler
2021-11-19 16:46:53.451 D/OneSignal: OneSignal SDK initialization already completed.
2021-11-19 16:46:53.460 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@920e1a1
2021-11-19 16:46:53.460 D/OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/notifications/d36dd8d4-18a1-4fdf-bddd-87908d2857e6
2021-11-19 16:46:53.460 D/OneSignal: Running startTimeout with timeout: 5000 and runnable: com.onesignal.OSNotificationOpenedResult$1@920e1a1
2021-11-19 16:46:53.466 D/OneSignal: OneSignalRestClient: PUT SEND JSON: {"app_id":"619bb485-4121-436c-97e2-660b16a18edd","player_id":"06f9df0c-c752-40d5-9a39-9886512d0a9a","opened":true,"device_type":1}
2021-11-19 16:46:53.507 I/WM-WorkerWrapper: Worker result FAILURE for Work [ id=555f060a-9fa2-4cfe-b55d-83ca78754e9a, tags={ com.onesignal.OSNotificationRestoreWorkManager$NotificationRestoreWorker } ]
2021-11-19 16:46:53.533 D/OneSignal: onActivityResumed: com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.533 D/OneSignal: curActivity is NOW: com.truckmap.truckmap.MainActivity:com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.533 D/OneSignal: ActivityLifecycleHandler handleFocus, with runnable: null nextResumeIsFirstActivity: false
2021-11-19 16:46:53.533 D/OneSignal: ActivityLifecycleHandler cancel background lost focus sync task
2021-11-19 16:46:53.533 D/OneSignal: OSFocusDelaySync cancel background sync
2021-11-19 16:46:53.540 D/ReactNativeNotifs: onHostResume
2021-11-19 16:46:53.540 D/ReactNativeNotifs: App is now visible
2021-11-19 16:46:53.540 E/OneSignal: Already initialized the OneSignal React-Native SDK
2021-11-19 16:46:53.580 D/OneSignal: onActivityDestroyed: com.onesignal.NotificationOpenedReceiver@e87608
2021-11-19 16:46:53.580 D/OneSignal: curActivity is NOW: com.truckmap.truckmap.MainActivity:com.truckmap.truckmap.MainActivity@8ff225d
2021-11-19 16:46:53.794 V/OneSignal: OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/notifications/d36dd8d4-18a1-4fdf-bddd-87908d2857e6
2021-11-19 16:46:53.794 D/OneSignal: OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/notifications/d36dd8d4-18a1-4fdf-bddd-87908d2857e6
2021-11-19 16:46:53.811 D/OneSignal: OneSignalRestClient: PUT RECEIVED JSON: {"success":true}
2021-11-19 16:46:55.051 I/ReactNativeJS:   unsubscribeWhenNotificationsAreDisabled: { [Function: nonPromiseMethodWrapper] type: 'async' },
      userProvidedPrivacyConsent: { [Function: promiseMethodWrapper] type: '
2021-11-19 16:46:55.614 I/ReactNativeJS: Configuring geolocation library
2021-11-19 16:46:58.413 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: true jsonBody: {"sdk_type":"react","loc_acc":33.431,"loc_type":1,"lat":39.1425766,"long":-86.5451033,"loc_bg":false,"loc_time_stamp":1637358205603,"app_id":"619bb485-4121-436c-97e2-660b16a18edd"}
2021-11-19 16:46:58.416 D/OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a/on_session
2021-11-19 16:46:58.419 D/OneSignal: OneSignalRestClient: POST SEND JSON: {"sdk_type":"react","loc_acc":33.431,"loc_type":1,"lat":39.1425766,"long":-86.5451033,"loc_bg":false,"loc_time_stamp":1637358205603,"app_id":"619bb485-4121-436c-97e2-660b16a18edd"}
2021-11-19 16:46:58.465 D/OneSignal: Running complete from OSNotificationOpenedResult timeout runnable!
2021-11-19 16:46:58.465 D/OneSignal: OSNotificationOpenedResult complete called with opened: false
2021-11-19 16:46:58.465 D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@920e1a1
2021-11-19 16:46:58.539 V/OneSignal: OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a/on_session
2021-11-19 16:46:58.539 D/OneSignal: OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/players/06f9df0c-c752-40d5-9a39-9886512d0a9a/on_session
2021-11-19 16:46:58.544 D/OneSignal: OneSignalRestClient: POST RECEIVED JSON: {"success":true,"id":"06f9df0c-c752-40d5-9a39-9886512d0a9a"}
2021-11-19 16:46:58.545 D/OneSignal: doCreateOrNewSession:response: {"success":true,"id":"06f9df0c-c752-40d5-9a39-9886512d0a9a"}
2021-11-19 16:46:58.546 I/OneSignal: Device registered, UserId = 06f9df0c-c752-40d5-9a39-9886512d0a9a
2021-11-19 16:47:03.548 D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: null

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!

@AkeleyUA
Copy link

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.

@sweatherall
Copy link
Author

@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.

@AkeleyUA
Copy link

@sweatherall Yes, I can confirm that. But this does not always work. Sometimes, even on the first try, it sees my application in the background.

@rgomezp
Copy link
Contributor

rgomezp commented Dec 16, 2021

Howdy,
Thanks for the info. We will try to reproduce.

@sujay-bidchat
Copy link

Any update on this?

@front-stream
Copy link

I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants