Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ public void run() {
sleepTime = MAX_WAIT_BETWEEN_RETRIES;

OneSignal.Log(OneSignal.LOG_LEVEL.INFO, "Failed to get Android parameters, trying again in " + (sleepTime / 1_000) + " seconds.");
OSUtils.sleep(sleepTime);
androidParamsRetries++;
makeAndroidParamsRequest(appId, userId, callback);
try {
Thread.sleep(sleepTime);
androidParamsRetries++;
makeAndroidParamsRequest(appId, userId, callback);
} catch (InterruptedException e) {
// Don't retry if something intentionally wants to stop this action
e.printStackTrace();
}
}
}, "OS_PARAMS_REQUEST").start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,25 @@ public void testOpeningLauncherActivity() throws Exception {
assertNull(shadowOf(blankActivity).getNextStartedActivity());
}

@Test
public void testOpeningLauncherActivityWhenOffline() throws Exception {
ShadowOneSignalRestClient.failGetParams = true;
AddLauncherIntentFilter();

OneSignalInit();
// This removes Activity from the unit test's state
assertNotNull(shadowOf(blankActivity).getNextStartedActivity());

// Background the app
blankActivityController.pause();

// Open a notification
OneSignal_handleNotificationOpen(blankActivity, new JSONArray("[{ \"alert\": \"Test Msg\", \"custom\": { \"i\": \"UUID\" } }]"), ONESIGNAL_NOTIFICATION_ID);

// Ensure the app is foregrounded
assertNotNull(shadowOf(blankActivity).getNextStartedActivity());
}

@Test
public void testOpeningLaunchUrl() throws Exception {
// First init run for appId to be saved
Expand Down