Skip to content

Focusing app through push notification does not work on Android 7 #1576

@curtisy1

Description

@curtisy1

Description:
A little similar to the comment here except we can consistently reproduce this on Android 7 (and possibly below) only.

Using the demo app from this repository, when keeping the app running in the background and keeping the device on home screen (it's not focused and not killed), opening a push notification results in ... nothing at all.
What should happen is the app being foregrounded as is already working with higher Android versions (note: Android 7.1.1 so API level 25 is working).
It's working fine if I press the back button to minimize the app or have any other app in the foreground.

Environment
Everything as in the sample
Compile SDK 31
OneSignal SDK 4.7.2

Steps to Reproduce Issue:

  1. Download the sample
  2. Bump the OneSignal SDK to latest and sync
  3. Start up an Android 7 (API Level 24) or possibly lower (or use a real device)
  4. Launch the app
  5. Hit the home button
  6. Send a push notification
  7. Tap or click the notification
  8. Instead of the app getting focused, you'll stay on the homescreen

Here's a Gif

Anything else:
Logcat from when the weirdness happens

2022-04-28 16:14:24.846 10026-10026/com.onesignal.sdktest D/OneSignal: onActivityPaused: com.onesignal.sdktest.activity.MainActivity@bb0d827
2022-04-28 16:14:24.846 10026-10026/com.onesignal.sdktest D/OneSignal: ActivityLifecycleHandler Handling lost focus
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest D/OneSignal: Application stopped focus time: 8167335 timeElapsed: 19
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:saveUnsentActiveData with lastFocusTimeInfluences: [SessionInfluence{influenceChannel=iam, influenceType=DISABLED, ids=null}, SessionInfluence{influenceChannel=notification, influenceType=DISABLED, ids=null}]
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 492
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:saveUnsentActiveTime: 511
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest V/OneSignal: OSFocusDelaySync scheduleSyncTask:SYNC_AFTER_BG_DELAY_MS: 2000
2022-04-28 16:14:24.847 10026-10026/com.onesignal.sdktest V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 2000
2022-04-28 16:14:24.913 10026-10026/com.onesignal.sdktest I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
2022-04-28 16:14:24.913 10026-10026/com.onesignal.sdktest D/OneSignal: curActivity is NOW: null
2022-04-28 16:14:24.925 10026-10077/com.onesignal.sdktest D/EGL_emulation: eglMakeCurrent: 0x9308b600: ver 2 0 (tinfo 0x9308a520)
2022-04-28 16:14:24.938 10026-10026/com.onesignal.sdktest D/OneSignal: onActivityStopped: com.onesignal.sdktest.activity.MainActivity@bb0d827
2022-04-28 16:14:24.938 10026-10026/com.onesignal.sdktest D/OneSignal: curActivity is NOW: null
2022-04-28 16:14:29.921 10026-10026/com.onesignal.sdktest D/OneSignal: ActivityLifecycleHandler runLostFocusLogic
2022-04-28 16:14:29.922 10026-10026/com.onesignal.sdktest D/OneSignal: OSBackground sync, calling initWithContext
2022-04-28 16:14:29.922 10026-10026/com.onesignal.sdktest V/OneSignal: initWithContext called with: com.onesignal.FocusDelaySyncJobService@37c56ee
2022-04-28 16:14:29.922 10026-10026/com.onesignal.sdktest V/OneSignal: Starting OneSignal initialization!
2022-04-28 16:14:29.923 10026-10026/com.onesignal.sdktest V/OneSignal: Found class: com.onesignal.sdktest.notification.NotificationServiceExtension, attempting to call constructor
2022-04-28 16:14:29.923 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SDK initialization already completed.
2022-04-28 16:14:29.926 10026-10121/com.onesignal.sdktest D/OneSignal: ActivityLifecycleHandler running AppFocusRunnable
2022-04-28 16:14:29.926 10026-10121/com.onesignal.sdktest D/OneSignal: Application lost focus initDone: true
2022-04-28 16:14:29.927 10026-10121/com.onesignal.sdktest D/OneSignal: Last session time set to: 1651155269926
2022-04-28 16:14:29.930 10026-10121/com.onesignal.sdktest D/OneSignal: GMSLocationController onFocusChange!
2022-04-28 16:14:29.930 10026-10121/com.onesignal.sdktest D/OneSignal: Application backgrounded focus time: 8167335
2022-04-28 16:14:29.930 10026-10121/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 511
2022-04-28 16:14:29.931 10026-10121/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:sendUnsentTimeNow with time: 511 and influences: []
2022-04-28 16:14:29.932 10026-10121/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed sendTime with: BACKGROUND
2022-04-28 16:14:29.932 10026-10121/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 511
2022-04-28 16:14:29.934 10026-10121/com.onesignal.sdktest V/OneSignal: OSSyncService scheduleSyncTask:SYNC_AFTER_BG_DELAY_MS: 30000
2022-04-28 16:14:29.934 10026-10121/com.onesignal.sdktest V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 30000
2022-04-28 16:14:29.937 10026-10121/com.onesignal.sdktest I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
2022-04-28 16:14:29.943 10026-10121/com.onesignal.sdktest D/OneSignal: OneSignal scheduleSyncService unsyncedChanges: false
2022-04-28 16:14:29.944 10026-10121/com.onesignal.sdktest D/OneSignal: LocationController scheduleUpdate not possible, location permission not enabled
2022-04-28 16:14:29.944 10026-10121/com.onesignal.sdktest D/OneSignal: OneSignal scheduleSyncService locationScheduled: false
2022-04-28 16:14:30.008 10026-10026/com.onesignal.sdktest V/OneSignal: initWithContext called with: android.app.ReceiverRestrictedContext@c2f0987
2022-04-28 16:14:30.008 10026-10026/com.onesignal.sdktest V/OneSignal: Starting OneSignal initialization!
2022-04-28 16:14:30.010 10026-10026/com.onesignal.sdktest V/OneSignal: Found class: com.onesignal.sdktest.notification.NotificationServiceExtension, attempting to call constructor
2022-04-28 16:14:30.010 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SDK initialization already completed.
2022-04-28 16:14:30.016 10026-10123/com.onesignal.sdktest D/OneSignal: OSNotificationWorkManager enqueueing notification work with notificationId: c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e and jsonPayload: {"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}
2022-04-28 16:14:30.059 10026-10129/com.onesignal.sdktest D/OneSignal: NotificationWorker running doWork with data: Data {timestamp : 1651155270, android_notif_id : 0, json_payload : {"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}, is_restoring : false, }
2022-04-28 16:14:30.062 10026-10129/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@abb8ab3
2022-04-28 16:14:30.062 10026-10129/com.onesignal.sdktest D/OneSignal: Running startTimeout with timeout: 25000 and runnable: com.onesignal.OSNotificationReceivedEvent$1@abb8ab3
2022-04-28 16:14:30.062 10026-10129/com.onesignal.sdktest V/OneSignal: OSRemoteNotificationReceivedHandler fired! with OSNotificationReceived: OSNotificationReceivedEvent{isComplete=false, notification=OSNotification{notificationExtender=null, groupedNotifications=null, androidNotificationId=0, notificationId='c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e', templateName='', templateId='', title='null', body='English Message', additionalData=null, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='872871203688', backgroundImageLayout=null, collapseId='null', priority=0, rawPayload='{"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}'}}
2022-04-28 16:14:30.062 10026-10129/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationReceivedEvent$1@abb8ab3
2022-04-28 16:14:30.063 10026-10129/com.onesignal.sdktest D/OneSignal: Starting processJobForDisplay opened: false fromBackgroundLogic: true
2022-04-28 16:14:30.064 10026-10129/com.onesignal.sdktest I/OneSignal: App is in background, show notification
2022-04-28 16:14:30.086 10026-10129/com.onesignal.sdktest D/OneSignal: Saving Notification job: OSNotificationGenerationJob{jsonPayload={"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}, isRestoring=false, shownTimeStamp=1651155270, overriddenBodyFromExtender=English Message, overriddenTitleFromExtender=null, overriddenSound=null, overriddenFlags=17, orgFlags=17, orgSound=null, notification=OSNotification{notificationExtender=com.onesignal.sdktest.notification.NotificationServiceExtension$$ExternalSyntheticLambda0@7a1283, groupedNotifications=null, androidNotificationId=307942866, notificationId='c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e', templateName='', templateId='', title='null', body='English Message', additionalData=null, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='872871203688', backgroundImageLayout=null, collapseId='null', priority=0, rawPayload='{"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}'}}
2022-04-28 16:14:30.103 10026-10129/com.onesignal.sdktest D/OneSignal: Notification saved values: expire_time=1651414470 notification_id=c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e opened=0 message=English Message android_notification_id=307942866 full_data={"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688"}
2022-04-28 16:14:30.105 10026-10129/com.onesignal.sdktest D/OneSignal: sendReceiveReceipt disabled
2022-04-28 16:14:30.106 10026-10129/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager onNotificationReceived notificationId: c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:30.106 10026-10129/com.onesignal.sdktest D/OneSignal: OneSignal OSChannelTracker for: notification_id saveLastId: c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:30.108 10026-10129/com.onesignal.sdktest D/OneSignal: OneSignal OSChannelTracker for: notification_id saveLastId with lastChannelObjectsReceived: [{"notification_id":"6bee9d14-56d4-4af2-954d-21ac7db7e662","time":1651154223232},{"notification_id":"debadf2d-896c-4afe-a29f-f8316f1460df","time":1651154335611},{"notification_id":"2e52a235-484a-487a-812a-20bba295c6e2","time":1651154601571},{"notification_id":"b5c9a7c2-a9e7-464c-aab4-31597324bda0","time":1651154613837},{"notification_id":"506ff5c6-a933-47ed-a009-d90aadd706bb","time":1651154626296},{"notification_id":"fe445e25-9dd1-4d2f-85a7-1233f3624747","time":1651154640918}]
2022-04-28 16:14:30.109 10026-10129/com.onesignal.sdktest D/OneSignal: OneSignal OSChannelTracker for: notification_id with channelObjectToSave: [{"notification_id":"6bee9d14-56d4-4af2-954d-21ac7db7e662","time":1651154223232},{"notification_id":"debadf2d-896c-4afe-a29f-f8316f1460df","time":1651154335611},{"notification_id":"2e52a235-484a-487a-812a-20bba295c6e2","time":1651154601571},{"notification_id":"b5c9a7c2-a9e7-464c-aab4-31597324bda0","time":1651154613837},{"notification_id":"506ff5c6-a933-47ed-a009-d90aadd706bb","time":1651154626296},{"notification_id":"fe445e25-9dd1-4d2f-85a7-1233f3624747","time":1651154640918},{"notification_id":"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e","time":1651155270108}]
2022-04-28 16:14:30.112 10026-10129/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@b114efb
2022-04-28 16:14:30.112 10026-10129/com.onesignal.sdktest D/OneSignal: Running startTimeout with timeout: 5000 and runnable: com.onesignal.OSNotificationOpenedResult$1@b114efb
2022-04-28 16:14:30.114 10026-10064/com.onesignal.sdktest I/WM-WorkerWrapper: Worker result SUCCESS for Work [ id=a5d8a26c-95ab-4880-a71d-6440b478910c, tags={ com.onesignal.OSNotificationWorkManager$NotificationWorker } ]
2022-04-28 16:14:34.875 10026-10026/com.onesignal.sdktest V/OneSignal: initWithContext called with: com.onesignal.sdktest.application.MainApplication@bf9d78
2022-04-28 16:14:34.875 10026-10026/com.onesignal.sdktest V/OneSignal: Starting OneSignal initialization!
2022-04-28 16:14:34.876 10026-10026/com.onesignal.sdktest V/OneSignal: Found class: com.onesignal.sdktest.notification.NotificationServiceExtension, attempting to call constructor
2022-04-28 16:14:34.876 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SDK initialization already completed.
2022-04-28 16:14:34.886 10026-10026/com.onesignal.sdktest D/OneSignal: processIntent from context: com.onesignal.NotificationOpenedReceiver@3dc00c4 and intent: Intent { flg=0x34800000 cmp=com.onesignal.sdktest/com.onesignal.NotificationOpenedReceiver (has extras) }
2022-04-28 16:14:34.886 10026-10026/com.onesignal.sdktest D/OneSignal: processIntent intent extras: Bundle[{androidNotificationId=307942866, onesignalData={"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688","androidNotificationId":307942866}}]
2022-04-28 16:14:34.892 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager onDirectInfluenceFromNotificationOpen notificationId: c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:34.892 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager attemptSessionUpgrade with entryAction: NOTIFICATION_CLICK
2022-04-28 16:14:34.893 10026-10026/com.onesignal.sdktest D/OneSignal: OSChannelTracker changed: notification_id
    from:
    influenceType: DIRECT, directNotificationId: 506ff5c6-a933-47ed-a009-d90aadd706bb, indirectNotificationIds: null
    to:
    influenceType: DIRECT, directNotificationId: c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e, indirectNotificationIds: null
2022-04-28 16:14:34.894 10026-10026/com.onesignal.sdktest D/OneSignal: Trackers changed to: [OSChannelTracker{tag=notification_id, influenceType=DIRECT, indirectIds=null, directId=c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e}, OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
2022-04-28 16:14:34.895 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager attemptSessionUpgrade channel updated, search for ending direct influences on channels: [OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
2022-04-28 16:14:34.895 10026-10148/com.onesignal.sdktest D/OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/notifications/c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:34.895 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager attemptSessionUpgrade try UNATTRIBUTED to INDIRECT upgrade
2022-04-28 16:14:34.895 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal ChannelTracker getLastReceivedIds lastChannelObjectReceived: []
2022-04-28 16:14:34.895 10026-10026/com.onesignal.sdktest D/OneSignal: Trackers after update attempt: [OSChannelTracker{tag=notification_id, influenceType=DIRECT, indirectIds=null, directId=c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e}, OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
2022-04-28 16:14:34.896 10026-10026/com.onesignal.sdktest D/OneSignal: OneSignal SessionManager sendSessionEndingWithInfluences with influences: [SessionInfluence{influenceChannel=notification, influenceType=DISABLED, ids=null}]
2022-04-28 16:14:34.897 10026-10026/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@bce772e
2022-04-28 16:14:34.897 10026-10026/com.onesignal.sdktest D/OneSignal: Running startTimeout with timeout: 5000 and runnable: com.onesignal.OSNotificationOpenedResult$1@bce772e
2022-04-28 16:14:34.900 10026-10149/com.onesignal.sdktest D/OneSignal: OneSignal cleanOutcomes for session
2022-04-28 16:14:34.900 10026-10148/com.onesignal.sdktest D/OneSignal: OneSignalRestClient: PUT SEND JSON: {"app_id":"xxxxxxx","player_id":"xxxxxxx","opened":true,"device_type":1}
2022-04-28 16:14:34.900 10026-10149/com.onesignal.sdktest D/OneSignal: OneSignal save unattributedUniqueOutcomeEvents: []
2022-04-28 16:14:34.900 10026-10026/com.onesignal.sdktest V/OneSignal: OSNotificationOpenedResult result: OSNotificationOpenedResult{notification=OSNotification{notificationExtender=null, groupedNotifications=[], androidNotificationId=307942866, notificationId='c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e', templateName='', templateId='', title='null', body='English Message', additionalData=null, smallIcon='null', largeIcon='null', bigPicture='null', smallIconAccentColor='null', launchURL='null', sound='null', ledColor='null', lockScreenVisibility=1, groupKey='null', groupMessage='null', actionButtons=null, fromProjectNumber='872871203688', backgroundImageLayout=null, collapseId='null', priority=0, rawPayload='{"google.sent_time":1651155270183,"google.ttl":259200,"custom":"{\"i\":\"c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e\"}","from":"872871203688","alert":"English Message","google.message_id":"0:1651155270203801%246c533ff9fd7ecd","google.c.sender.id":"872871203688","androidNotificationId":307942866}'}, action=com.onesignal.OSNotificationAction@fa3365, isComplete=false}
2022-04-28 16:14:34.902 10026-10149/com.onesignal.sdktest D/OneSignal: FocusTimeProcessorUnattributed sendTime with: END_SESSION
2022-04-28 16:14:34.930 10026-10026/com.onesignal.sdktest D/OneSignal: onActivityDestroyed: com.onesignal.NotificationOpenedReceiver@3dc00c4
2022-04-28 16:14:34.932 10026-10026/com.onesignal.sdktest D/OneSignal: curActivity is NOW: null
2022-04-28 16:14:35.082 10026-10148/com.onesignal.sdktest V/OneSignal: OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/notifications/c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:35.082 10026-10148/com.onesignal.sdktest D/OneSignal: OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/notifications/c2a87f40-7e19-43b3-9c11-bdfbdc8f5e5e
2022-04-28 16:14:35.084 10026-10148/com.onesignal.sdktest D/OneSignal: OneSignalRestClient: PUT RECEIVED JSON: {"success":true}
2022-04-28 16:14:35.150 10026-10130/com.onesignal.sdktest D/OneSignal: Running complete from OSNotificationOpenedResult timeout runnable!
2022-04-28 16:14:35.150 10026-10130/com.onesignal.sdktest D/OneSignal: OSNotificationOpenedResult complete called with opened: false
2022-04-28 16:14:35.150 10026-10130/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@b114efb
2022-04-28 16:14:39.939 10026-10130/com.onesignal.sdktest D/OneSignal: Running complete from OSNotificationOpenedResult timeout runnable!
2022-04-28 16:14:39.939 10026-10130/com.onesignal.sdktest D/OneSignal: OSNotificationOpenedResult complete called with opened: false
2022-04-28 16:14:39.939 10026-10130/com.onesignal.sdktest D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSNotificationOpenedResult$1@bce772e

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions