Skip to content

Commit

Permalink
Add conditional to handle converting booleans to string representation
Browse files Browse the repository at this point in the history
Ensures that boolean values are consistently handled as 'true' or 'false' strings instead of numeric representations.
  • Loading branch information
jennantilla committed Dec 5, 2023
1 parent 19a39a3 commit 9e60bd7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ios/OneSignalPush.m
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,12 @@ - (void)addTags:(CDVInvokedUrlCommand*)command {

for (id key in tags) {
id value = tags[key];
convertedTags[key] = [value isKindOfClass:[NSString class]] ? value : [NSString stringWithFormat:@"%@", value];

if ([value isKindOfClass:[NSNumber class]] && CFGetTypeID((__bridge CFTypeRef)(value)) == CFBooleanGetTypeID()) {
convertedTags[key] = [value boolValue] ? @"true" : @"false";
} else {
convertedTags[key] = [value isKindOfClass:[NSString class]] ? value : [NSString stringWithFormat:@"%@", value];
}
}

[OneSignal.User addTags:convertedTags];
Expand Down

0 comments on commit 9e60bd7

Please sign in to comment.