Skip to content

Commit d6dc273

Browse files
committed
received_receipts_nil_app_and_player_id_handling
* Adding nil to a NSDictionary will crash. * If we don't have an app_id don't send, our wrapper around need work requests ensures this is always present. * Use NSNull to send a JSON null when there isn't a player_id however.
1 parent 4e73bf6 commit d6dc273

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

iOS_SDK/OneSignalSDK/Source/OneSignalReceiveReceiptsController.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,17 @@ - (void)sendReceiveReceiptWithPlayerId:(nonnull NSString *)playerId
6666
let message = [NSString stringWithFormat:@"OneSignal sendReceiveReceiptWithPlayerId playerId:%@ notificationId: %@, appId: %@", playerId, notificationId, appId];
6767
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:message];
6868

69+
if (!appId) {
70+
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"appId not available from shared UserDefaults!"];
71+
return;
72+
}
73+
6974
if (![self isReceiveReceiptsEnabled]) {
7075
[OneSignal onesignal_Log:ONE_S_LL_VERBOSE message:@"Receieve receipts disabled"];
7176
return;
7277
}
7378

74-
OSRequestReceiveReceipts *request = [OSRequestReceiveReceipts withPlayerId:playerId notificationId:notificationId appId:appId];
79+
let request = [OSRequestReceiveReceipts withPlayerId:playerId notificationId:notificationId appId:appId];
7580
[OneSignalClient.sharedClient executeRequest:request onSuccess:^(NSDictionary *result) {
7681
if (success)
7782
success(result);

iOS_SDK/OneSignalSDK/Source/Requests.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ @implementation OSRequestReceiveReceipts
463463

464464
+ (instancetype _Nonnull)withPlayerId:(NSString *)playerId notificationId:(NSString *)notificationId appId:(NSString *)appId {
465465
let request = [OSRequestReceiveReceipts new];
466-
request.parameters = @{@"app_id" : appId, @"player_id" : playerId};
466+
467+
request.parameters = @{@"app_id": appId, @"player_id": playerId ?: [NSNull null]};
467468
request.method = PUT;
468469
request.path = [NSString stringWithFormat:@"notifications/%@/report_received", notificationId];
469470

0 commit comments

Comments
 (0)