Skip to content

Commit

Permalink
rm waiting on params network call on notifi open
Browse files Browse the repository at this point in the history
This fixes a bug where the app would not be brought to the foreground
when tapping on a notification if the app could not connect to
onesignal.com or was offline during the full life time of the app
process.
This also fixes another a compatibility issue with Xiaomi devices where
the app would not foreground if the app process was dead and also no
task exists in the recent list.

It is critical we don't wait for a network call for the notification
open logic this method does the work to bring the app to the foreground.
This get params network call isn't needed before we handle the
notification open logic anyway.

This network wait was present in 4.0.0 through 4.4.x but was not an
issue in 4.5.0 when a "Reverse Activity Trampoline" was setup. However
in PR #1581 we are switching back to a standard Activity Trampoline and
we don't want to reintroduce this bug.

A failing test was added for this in a previous commit, which now
passes.
  • Loading branch information
jkasten2 committed May 14, 2022
1 parent 89fb595 commit 23cc934
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions OneSignalSDK/onesignal/src/main/java/com/onesignal/OneSignal.java
Original file line number Diff line number Diff line change
Expand Up @@ -2395,22 +2395,6 @@ static void fireForegroundHandlers(OSNotificationController notificationControll
* Method called when opening a notification
*/
static void handleNotificationOpen(final Activity context, final JSONArray data, @Nullable final String notificationId) {
// Delay call until remote params are set
if (taskRemoteController.shouldQueueTaskForInit(OSTaskRemoteController.HANDLE_NOTIFICATION_OPEN)) {
logger.error("Waiting for remote params. " +
"Moving " + OSTaskRemoteController.HANDLE_NOTIFICATION_OPEN + " operation to a pending queue.");
taskRemoteController.addTaskToQueue(new Runnable() {
@Override
public void run() {
if (appContext != null) {
logger.debug("Running " + OSTaskRemoteController.HANDLE_NOTIFICATION_OPEN + " operation from pending queue.");
handleNotificationOpen(context, data, notificationId);
}
}
});
return;
}

// If applicable, check if the user provided privacy consent
if (shouldLogUserPrivacyConsentErrorMessageForMethodName(null))
return;
Expand Down

0 comments on commit 23cc934

Please sign in to comment.