Skip to content

Commit bf30e0e

Browse files
committed
Fixed merge conflict with received receipts
* Also made OSReceivedReceiptsController a singleton.
1 parent 94730ea commit bf30e0e

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,16 @@ private static void saveAndProcessNotification(Context context, Bundle bundle, b
145145
}
146146

147147
/**
148-
* Must call this method instead of saveNotification
149-
*
150-
* This send receive receipt call
148+
* Save notification, updates Outcomes, and sends Received Receipt if they are enabled.
151149
*/
152150
static void processNotification(NotificationGenerationJob notifiJob, boolean opened) {
153151
saveNotification(notifiJob, opened);
154-
OSReceiveReceiptController controller = new OSReceiveReceiptController();
155-
controller.sendReceiveReceipt(notifiJob.getApiNotificationId());
152+
153+
if (!notifiJob.isNotificationToDisplay())
154+
return;
155+
String notificationId = notifiJob.getApiNotificationId();
156+
OutcomesUtils.markLastNotificationReceived(notificationId);
157+
OSReceiveReceiptController.getInstance().sendReceiveReceipt(notificationId);
156158
}
157159

158160
// Saving the notification provides the following:

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ class OSReceiveReceiptController {
3333

3434
private final OSReceiveReceiptRepository repository;
3535

36-
OSReceiveReceiptController() {
36+
private static OSReceiveReceiptController sInstance;
37+
private OSReceiveReceiptController() {
3738
this.repository = new OSReceiveReceiptRepository();
3839
}
40+
public static synchronized OSReceiveReceiptController getInstance() {
41+
if (sInstance == null)
42+
sInstance = new OSReceiveReceiptController();
43+
return sInstance;
44+
}
3945

4046
void sendReceiveReceipt(@NonNull final String notificationId) {
4147
String appId = OneSignal.appId == null || OneSignal.appId.isEmpty() ? OneSignal.getSavedAppId() : OneSignal.appId;

0 commit comments

Comments
 (0)