-->

How to detect if the phone app is available for va

2019-03-16 23:40发布

问题:

I'd like to show or hide a button that lets a user make a phone call based on whether or not the user can actually make a call (iPhone or iPod touch). Is it possible to somehow detect if the phone app is available to the user in cocoa-touch? Or am i constrained to detecting the device type to make that distinction? I would rather check for functionality than static clients in case something changes down the line for whatever reason (not that iPod touch users could ever make non-voip phone calls anyways, but the code would be cleaner).

回答1:

BOOL canMakePhoneCalls = [[UIApplication sharedApplication]
                           canOpenURL:[NSURL URLWithString:@"tel:5555555"]];