|
|
@ -214,10 +214,28 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
|
|
|
|
|
|
|
|
|
|
|
|
- (void)populateDefaultCountryNameAndCode
|
|
|
|
- (void)populateDefaultCountryNameAndCode
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSLocale *locale = NSLocale.currentLocale;
|
|
|
|
PhoneNumber *localNumber = [PhoneNumber phoneNumberFromE164:[TSAccountManager localNumber]];
|
|
|
|
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
|
|
|
|
OWSAssert(localNumber);
|
|
|
|
NSNumber *callingCode = [[PhoneNumberUtil sharedUtil].nbPhoneNumberUtil getCountryCodeForRegion:countryCode];
|
|
|
|
|
|
|
|
|
|
|
|
NSString *countryCode;
|
|
|
|
|
|
|
|
NSNumber *callingCode;
|
|
|
|
|
|
|
|
if (localNumber) {
|
|
|
|
|
|
|
|
callingCode = [localNumber getCountryCode];
|
|
|
|
|
|
|
|
OWSAssert(callingCode);
|
|
|
|
|
|
|
|
if (callingCode) {
|
|
|
|
|
|
|
|
countryCode = [[PhoneNumberUtil sharedUtil]
|
|
|
|
|
|
|
|
probableCountryCodeForCallingCode:[@"+" stringByAppendingString:[callingCode description]]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!countryCode || !callingCode) {
|
|
|
|
|
|
|
|
NSLocale *locale = NSLocale.currentLocale;
|
|
|
|
|
|
|
|
countryCode = [locale objectForKey:NSLocaleCountryCode];
|
|
|
|
|
|
|
|
callingCode = [[PhoneNumberUtil sharedUtil].nbPhoneNumberUtil getCountryCodeForRegion:countryCode];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSString *countryName = [PhoneNumberUtil countryNameFromCountryCode:countryCode];
|
|
|
|
NSString *countryName = [PhoneNumberUtil countryNameFromCountryCode:countryCode];
|
|
|
|
|
|
|
|
|
|
|
|
[self updateCountryWithName:countryName
|
|
|
|
[self updateCountryWithName:countryName
|
|
|
|
callingCode:[NSString stringWithFormat:@"%@%@", COUNTRY_CODE_PREFIX, callingCode]
|
|
|
|
callingCode:[NSString stringWithFormat:@"%@%@", COUNTRY_CODE_PREFIX, callingCode]
|
|
|
|
countryCode:countryCode];
|
|
|
|
countryCode:countryCode];
|
|
|
|