适配iOS10 调取系统打电话功能
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
[NSString stringWithFormat:@"tel:%@",cell.detailTextLabel.text]]
options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@(NO)}
completionHandler:nil];
此处关键在于options的设置:
在UIApplication.h 处有提供
// Option for openURL:options:CompletionHandler: only open URL if it is a valid universal link with an application configured to open it
// If there is no application configured, or the user disabled using it to
open the link, completion handler called with NO
UIKIT_EXTERN NSString *const UIApplicationOpenURLOptionUniversalLinksOnly NS_AVAILABLE_IOS(10_0);
设置UIApplicationOpenURLOptionUniversalLinksOnly为YES并打开URL时, 如果用户并没有安装app那它就会失败,同时会调用safari来打开这个链接。
友情链接:
技术博客 简书主页