How to get the user s country calling code in iOS

0 votes
I am developing an iOS app in which the user enters their mobile number. How do I get their country calling code? For example, if a user is in India, then +91 should be prefixed automatically. Is there an option that adds country codes automatically?
Nov 22, 2022 in Mobile Development by gaurav
• 25,250 points
• 3,457 views

1 answer to this question.

0 votes

Import Statement :

#import<CoreTelephony/CTCarrier.h>
#import <CoreTelephony/CTTelephonyNetworkInfo.h>

you can get country code for the current Carrier using CoreTelephony framework:

CTTelephonyNetworkInfo *network_Info = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = network_Info.subscriberCellularProvider;

NSLog(@"country code is: %@", carrier.mobileCountryCode);

//will return the actual country code
NSLog(@"ISO country code is: %@", carrier.isoCountryCode);
answered Dec 15, 2022 by gaurav
• 25,250 points

Related Questions In Mobile Development

0 votes
0 answers

How to draw heart shape in UIView (iOS)?

I want to create different shapes. Below ...READ MORE

Nov 10, 2022 in Mobile Development by gaurav
• 25,250 points
• 1,711 views
0 votes
1 answer

How to create custom Document Icon in iOS 14+ apps

Tap Add to Home Screen and select ...READ MORE

answered Dec 15, 2022 in Mobile Development by gaurav
• 25,250 points
• 2,219 views
0 votes
0 answers

Change English Number To Persian Numbers in Text Swift,IOS

Hi How can i replace english numbers ...READ MORE

Nov 8, 2022 in Mobile Development by gaurav
• 25,250 points
• 1,515 views
0 votes
1 answer

Xcode 13.2.1 error when running on phone with iOS 15.4.1

Check /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/ for directory name 15.4 (your ...READ MORE

answered Dec 15, 2022 in Mobile Development by gaurav
• 25,250 points
• 2,659 views