Cant able to get phone number from iphone
1,708
Solution 1
There is no supported way to get the device's phone number. Any method (such as "SBFormattedPhoneNumber" mentioned in the other answers) that happens to work for now is liable to get your app rejected and is liable to stop working at any point without notice.
If you need the phone number, just ask the user to enter it.
Solution 2
Use below code
To Store a phone number string
[[NSUserDefaults standardUserDefaults] setObject:@"1234567890")
forKey:@"SBFormattedPhoneNumber"];
To get the phone string back.
NSString* num = [[NSUserDefaults standardUserDefaults] objectForKey:@"SBFormattedPhoneNumber"];
Read the blog tutorial.
http://ayeapi.blogspot.com/2009/12/sbformatphonenumber-is-lie.html
Related videos on Youtube
Author by
siva
Updated on November 20, 2022Comments
-
siva over 1 year
Currently I'm using the following code to get the local device phone number :
NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@”SBFormattedPhoneNumber”]; NSLog(@”Phone Number: %@”, num);
but it can't able to get the number, it shows null. Can any one guide me how to solve this problem!!
Thanks in advance
-
Nate over 11 yearsplease don't just copy other answers. if the answer is on stack overflow, a simple link will suffice. thanks.