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
• 23,260 points
1,345 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
• 23,260 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
• 23,260 points
749 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
• 23,260 points
799 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
• 23,260 points
534 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
• 23,260 points
1,400 views
+2 votes
2 answers

how to set different provisioning profiles for different targets using Xcode Build

For multiple targets, each task has to ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by ajs3033
• 7,300 points

edited Oct 16, 2018 by Kalgi 5,094 views
0 votes
1 answer

URL Scheme for iOS Home App

I think you could try doing it ...READ MORE

answered Nov 16, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,253 views
0 votes
1 answer

swift for windows? xcode on windows? ?

Hi, @Aminegac, If you’re a little more technically ...READ MORE

answered Dec 4, 2020 in Others by Nikita
1,967 views
0 votes
0 answers

How to get original image when we zoom in and zoom out the image in ios

Hi i am beginner in ios and ...READ MORE

Nov 17, 2022 in Mobile Development by gaurav
• 23,260 points
774 views
0 votes
0 answers

How to fetch the width and height of a programatically added view in Swift/ iOS?

I have added a UIView and a ...READ MORE

Nov 10, 2022 in Mobile Development by gaurav
• 23,260 points
1,256 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP