Skip to content

Commit 9cab6af

Browse files
committed
Cancel Worker thread if notification nor processed
* Notification might not be processed if it is a restored one or an IAM
1 parent 117074f commit 9cab6af

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationBundleProcessor.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ private static int processJobForDisplay(OSNotificationController notificationCon
165165
String osNotificationId = OSNotificationFormatHelper.getOSNotificationIdFromJson(notificationController.getNotificationJob().getJsonPayload());
166166
OSNotificationWorkManager.removeNotificationIdProcessed(osNotificationId);
167167
OneSignal.handleNotificationReceived(notificationJob);
168+
} else {
169+
CallbackToFutureAdapter.Completer<ListenableWorker.Result> callbackCompleter = notificationJob.getCallbackCompleter();
170+
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "Process notification restored or IAM with callback completer: " + callbackCompleter);
171+
if (callbackCompleter != null)
172+
callbackCompleter.set(ListenableWorker.Result.success());
168173
}
169174

170175
return androidNotificationId;

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSNotificationWorkManager.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ static void removeNotificationIdProcessed(String osNotificationId) {
5555

5656
static void beginEnqueueingWork(Context context, String osNotificationId, int androidNotificationId, String jsonPayload, long timestamp,
5757
boolean isRestoring, boolean isHighPriority, boolean needsWorkerThread) {
58-
5958
if (!needsWorkerThread) {
6059
try {
6160
JSONObject jsonPayloadObject = new JSONObject(jsonPayload);

OneSignalSDK/unittest/src/test/java/com/test/onesignal/GenerateNotificationRunner.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,6 @@ public void shouldShowInAppPreviewWhenOpeningPreviewNotification() throws Except
12561256
@Test
12571257
@Config(shadows = { ShadowGenerateNotification.class })
12581258
public void shouldSendReceivedReceiptWhenEnabled() throws Exception {
1259-
12601259
ShadowOneSignalRestClient.setRemoteParamsReceiveReceiptsEnable(true);
12611260

12621261
String appId = "b2f7f966-d8cc-11e4-bed1-df8f05be55ba";

0 commit comments

Comments
 (0)