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
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ synchronized public static OSReceiveReceiptController getInstance() {
void sendReceiveReceipt(final CallbackToFutureAdapter.Completer<ListenableWorker.Result> callbackCompleter, @NonNull final String notificationId) {
final String appId = OneSignal.appId == null || OneSignal.appId.isEmpty() ? OneSignal.getSavedAppId() : OneSignal.appId;
final String playerId = OneSignal.getUserId();
final int deviceType = new OSUtils().getDeviceType();

if (!remoteParamController.isReceiveReceiptEnabled()) {
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "sendReceiveReceipt disable");
Expand All @@ -64,7 +65,7 @@ void sendReceiveReceipt(final CallbackToFutureAdapter.Completer<ListenableWorker
Runnable receiveReceiptRunnable = new Runnable() {
@Override
public void run() {
repository.sendReceiveReceipt(appId, playerId, notificationId, new OneSignalRestClient.ResponseHandler() {
repository.sendReceiveReceipt(appId, playerId, deviceType, notificationId, new OneSignalRestClient.ResponseHandler() {
@Override
void onSuccess(String response) {
OneSignal.Log(OneSignal.LOG_LEVEL.DEBUG, "Receive receipt sent for notificationID: " + notificationId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ class OSReceiveReceiptRepository {

private static final String APP_ID = "app_id";
private static final String PLAYER_ID = "player_id";
private static final String DEVICE_TYPE = "device_type";

void sendReceiveReceipt(@NonNull String appId, @NonNull String playerId, @NonNull String notificationId, @NonNull OneSignalRestClient.ResponseHandler responseHandler) {
void sendReceiveReceipt(@NonNull String appId, @NonNull String playerId, @NonNull int deviceType, @NonNull String notificationId, @NonNull OneSignalRestClient.ResponseHandler responseHandler) {
try {
JSONObject jsonBody = new JSONObject()
.put(APP_ID, appId)
.put(PLAYER_ID, playerId);
.put(PLAYER_ID, playerId)
.put(DEVICE_TYPE, deviceType);

OneSignalRestClient.put("notifications/" + notificationId + "/report_received", jsonBody, responseHandler);
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,10 @@ public void shouldSendReceivedReceiptWhenEnabled() throws Exception {
assertReportReceivedAtIndex(
2,
"UUID",
new JSONObject().put("app_id", appId).put("player_id", ShadowOneSignalRestClient.pushUserId)
new JSONObject()
.put("app_id", appId)
.put("player_id", ShadowOneSignalRestClient.pushUserId)
.put("device_type", 1)
);
}

Expand Down