Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-3226 Carrier & Country Code changes above iOS 16 #290

Merged
merged 1 commit into from
Sep 29, 2023
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
15 changes: 13 additions & 2 deletions CleverTapSDK/CTDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,25 @@ - (BOOL)wifi {

- (NSString *)carrier {
if (!_carrier) {
_carrier = [self getCarrier].carrierName ?: @"";
if (@available(iOS 16.0, *)) {
// CTCarrier is deprecated above iOS version 16 with no replacements so carrierName will be empty.
_carrier = @"";
} else {
_carrier = [self getCarrier].carrierName ?: @"";
}
}
return _carrier;
}

- (NSString *)countryCode {
if (!_countryCode) {
_countryCode = [self getCarrier].isoCountryCode ?: @"";
if (@available(iOS 16.0, *)) {
// CTCarrier is deprecated above iOS version 16 with no replacements so used NSLocale to get isoCountryCode.
NSLocale *currentLocale = [NSLocale currentLocale];
_countryCode = [currentLocale objectForKey:NSLocaleCountryCode];
} else {
_countryCode = [self getCarrier].isoCountryCode ?: @"";
}
}
return _countryCode;
}
Expand Down
2 changes: 1 addition & 1 deletion CleverTapSDK/CleverTap.m
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ - (NSDictionary *)generateAppFields {
evtData[@"Make"] = self.deviceInfo.manufacturer;
evtData[@"OS Version"] = self.deviceInfo.osVersion;

if (self.deviceInfo.carrier) {
if (self.deviceInfo.carrier && ![self.deviceInfo.carrier isEqualToString:@""]) {
evtData[@"Carrier"] = self.deviceInfo.carrier;
}

Expand Down
Loading