Skip to content

Commit a241b6a

Browse files
authored
Merge pull request #961 from OneSignal/fix/calling_nil_failureBlock
Fix/calling nil failure block and OneSignal.h set to public
2 parents e24076e + 7d727bd commit a241b6a

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@
364364
A63E9E4026742C1600EA273E /* LanguageProviderAppDefined.h in Headers */ = {isa = PBXBuildFile; fileRef = A6B519A82669747B00AED40E /* LanguageProviderAppDefined.h */; };
365365
A63E9E4126742C1800EA273E /* LanguageProviderDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = A6B519AB2669749100AED40E /* LanguageProviderDevice.h */; };
366366
A662399326850DDE00D52FD8 /* LanguageTest.m in Sources */ = {isa = PBXBuildFile; fileRef = A662399026850DDE00D52FD8 /* LanguageTest.m */; };
367-
A66239952686612F00D52FD8 /* OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 912411F01E73342200E41FD7 /* OneSignal.h */; };
367+
A66239952686612F00D52FD8 /* OneSignal.h in Headers */ = {isa = PBXBuildFile; fileRef = 912411F01E73342200E41FD7 /* OneSignal.h */; settings = {ATTRIBUTES = (Public, ); }; };
368368
A6B519A62669614A00AED40E /* LanguageContext.m in Sources */ = {isa = PBXBuildFile; fileRef = A6B519A52669614A00AED40E /* LanguageContext.m */; };
369369
A6B519AA2669747B00AED40E /* LanguageProviderAppDefined.m in Sources */ = {isa = PBXBuildFile; fileRef = A6B519A92669747B00AED40E /* LanguageProviderAppDefined.m */; };
370370
A6B519AD2669749100AED40E /* LanguageProviderDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = A6B519AC2669749100AED40E /* LanguageProviderDevice.m */; };

iOS_SDK/OneSignalSDK/Source/OneSignal.m

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,26 +1263,32 @@ + (void)sendTags:(NSDictionary*)keyValuePair onSuccess:(OSResultSuccessBlock)suc
12631263

12641264
// return if the user has not granted privacy permissions
12651265
if ([self shouldLogMissingPrivacyConsentErrorWithMethodName:@"sendTags:onSuccess:onFailure:"]) {
1266-
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : @"Your application has called sendTags:onSuccess:onFailure: before the user granted privacy permission. Please call `consentGranted(bool)` in order to provide user privacy consent"}];
1267-
failureBlock(error);
1266+
if (failureBlock) {
1267+
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : @"Your application has called sendTags:onSuccess:onFailure: before the user granted privacy permission. Please call `consentGranted(bool)` in order to provide user privacy consent"}];
1268+
failureBlock(error);
1269+
}
12681270
return;
12691271
}
12701272

12711273

12721274
if (![NSJSONSerialization isValidJSONObject:keyValuePair]) {
12731275
NSString *errorMessage = [NSString stringWithFormat:@"sendTags JSON Invalid: The following key/value pairs you attempted to send as tags are not valid JSON: %@", keyValuePair];
12741276
onesignal_Log(ONE_S_LL_WARN, errorMessage);
1275-
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : errorMessage}];
1276-
failureBlock(error);
1277+
if (failureBlock) {
1278+
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : errorMessage}];
1279+
failureBlock(error);
1280+
}
12771281
return;
12781282
}
12791283

12801284
for (NSString *key in [keyValuePair allKeys]) {
12811285
if ([keyValuePair[key] isKindOfClass:[NSDictionary class]]) {
12821286
NSString *errorMessage = @"sendTags Tags JSON must not contain nested objects";
12831287
onesignal_Log(ONE_S_LL_WARN, errorMessage);
1284-
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : errorMessage}];
1285-
failureBlock(error);
1288+
if (failureBlock) {
1289+
NSError *error = [NSError errorWithDomain:@"com.onesignal.tags" code:0 userInfo:@{@"error" : errorMessage}];
1290+
failureBlock(error);
1291+
}
12861292
return;
12871293
}
12881294
}

0 commit comments

Comments
 (0)