iOS 从app跳转到Safari、从app打开电话呼叫

时间:2022-07-23 20:50:50

1.从app跳转到Safari

 NSString* strIdentifier = @"http://www.ybyb.com";
BOOL isExsit = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:strIdentifier]];
if(isExsit) {
NSLog(@"App %@ installed", strIdentifier);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:strIdentifier]];
}

2.从app打开电话呼叫

  NSString *phoneNum = @"";// 电话号码

         UIWebView *phoneCallWebView;
NSURL *phoneURL = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNum]];
if ( !phoneCallWebView ) {
phoneCallWebView = [[UIWebView alloc] initWithFrame:CGRectZero];// 这个webView只是一个后台的View 不需要add到页面上来 }
[phoneCallWebView loadRequest:[NSURLRequest requestWithURL:phoneURL]]; [self.view addSubview:phoneCallWebView];