// 在App A 中打开 App B
// 1.0 在 App B Info.Plist URL Types 添加Schemes . 必填id(com.xxx.abc) 和 URL Schemes(ABC)
// 2.0 在 App A Info.plist LSApplicationQueriesSchemes 中添加item value 为要跳转的URL Schemes(ABC)
// 3.0 在App A中要跳转的位置 调用 [UIApplication sharedApplication] openUrl: URl的值为 ABC://com.xxx.abc
- (void)checkWhetherHasInstalledAppWithUrlSchemes:(NSString*)urlSchemes resultBlock:(void(^)(BOOLsuccess))resultBlock {
NSURL*URL = [NSURLURLWithString:urlSchemes];
UIApplication *application = [UIApplication sharedApplication];
if([applicationcanOpenURL:URL]) {
if([applicationrespondsToSelector:@selector(openURL:options:completionHandler:)]) {
// iOS10及以上判断方式
[applicationopenURL:URLoptions:@{}
completionHandler:^(BOOLsuccess) {
if(resultBlock) {
resultBlock(success);
}
}];
}else{
BOOLsuccess = [applicationopenURL:URL];
if(resultBlock) {
resultBlock(success);
}
}
}else{
if(resultBlock) {
resultBlock(NO);
}
}
}
网友评论