更新时间:2022-06-01 21:55:16
canOpenURL
本质上是检查是否已安装注册到该特定URL方案的应用程序,或者换句话说,是否存在该应用程序,以及是否已安装该应用程序,我们可以打开URL.
canOpenURL
is the essentially checks whether the app that is registered to that particular URL scheme is installed or in other words if the app exists, and if it is, we can open the URL.
- (BOOL) appExists: (NSURL*)url{
if ([[UIApplication sharedApplication] canOpenURL:url]) {
return YES;
} else {
return NO;
}
}
NSURL *urlApp = [NSURL URLWithString:@"fb://profile/73728918115"];// facebook app
NSURL *urlApp = [NSURL URLWithString: [NSString stringWithFormat:@"%@", @"twitter:///user?screen_name=INNOVA_ET_BELLA"]];//tweeter app
if ([self appExists:urlApp]) {
[[UIApplication sharedApplication] openURL:urlApp];
}
iPhone URL方案:
IPhone URL Schemes:
http://wiki.akosma.com/IPhone_URL_Schemes
自定义URL方案:
http://mobiledevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html