Search code examples
iphoneiosphone-number

asking for permission from the user to autodetect SIM phone number - xCode


There's a forbidden function by apple for getting a user's phone number because this may be intrusive and so on.

this is the code as far as I know

NSString *num = [[NSUserDefaults standardUserDefaults] stringForKey:@"SBFormattedPhoneNumber"];

I was wondering... what about before doing that the app should be displaying in a UIAlertView the approval of the user for such action, is that a valid solution???

thanks in advance folks!


Solution

  • The thing with undocumented functions is that they can't be relied upon. Any version update could break them. That said, the bigger issue is if Apple will approve an app that uses such a call. If not (consensus seems to be that they are not in favor of using SBFormattedPhoneNumber) then simply asking the user for permission before doing it will probably not buy you any points in the approval process. My suggestion would be to avoid this and simply ask the user for their phone number if you need it.