[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
[NSString stringWithFormat:@"tel:%@",cell.detailTextLabel.text]]
options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@(NO)}
completionHandler:nil];
此處關(guān)鍵在于options的設(shè)置:
在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);
設(shè)置UIApplicationOpenURLOptionUniversalLinksOnly為YES并打開URL時, 如果用戶并沒有安裝app那它就會失敗钙蒙,同時會調(diào)用safari來打開這個鏈接。
參見:
What's New in iOS -查看UIKit 部分
Querying URL Schemes with canOpenURL
? ?
? ?
? ?
友情鏈接:
技術(shù)博客 ???????簡書主頁