Skip to content

Commit

Permalink
Nil Block Checks (#394)
Browse files Browse the repository at this point in the history
• In the OneSignalClient class that handles network request logic, there were rare cases where the SDK was attempting to execute blocks that could potentially be nil
• Adds checks to ensure these blocks aren't executed if they're nil (fixes #391)
  • Loading branch information
Nightsd01 authored Aug 6, 2018
1 parent b5ac58b commit aaa056e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions iOS_SDK/OneSignalSDK/Source/OneSignalClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@ - (void)executeSimultaneousRequests:(NSDictionary<NSString *, OneSignalRequest *
- (void)executeRequest:(OneSignalRequest *)request onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSFailureBlock)failureBlock {

if (request.method != GET && [OneSignal shouldLogMissingPrivacyConsentErrorWithMethodName:nil]) {
failureBlock([NSError errorWithDomain:@"OneSignal Error" code:0 userInfo:@{@"error" : [NSString stringWithFormat:@"Attempted to perform an HTTP request (%@) before the user provided privacy consent.", NSStringFromClass(request.class)]}]);
if (failureBlock) {
failureBlock([NSError errorWithDomain:@"OneSignal Error" code:0
userInfo:@{@"error" : [NSString stringWithFormat:
@"Attempted to perform an HTTP request (%@) before the user provided privacy consent.", NSStringFromClass(request.class)]}]);
}

return;
}

Expand Down Expand Up @@ -156,7 +161,8 @@ - (void)handleMissingAppIdError:(OSFailureBlock)failureBlock withRequest:(OneSig

[OneSignal onesignal_Log:ONE_S_LL_ERROR message:errorDescription];

failureBlock([NSError errorWithDomain:@"OneSignalError" code:-1 userInfo:@{@"error" : errorDescription}]);
if (failureBlock)
failureBlock([NSError errorWithDomain:@"OneSignalError" code:-1 userInfo:@{@"error" : errorDescription}]);
}

- (BOOL)validRequest:(OneSignalRequest *)request {
Expand Down

0 comments on commit aaa056e

Please sign in to comment.