陈斌彬的技术博客

Stay foolish,stay hungry

iOS 应用之间调用

1.在appA的info.plist中定义URL,就是在文件中添加URL types一项。可按下图进行添加

img

2.在appB的代码中打开刚才定义的URL,代码如下

NSURL *url = [NSURL URLWithString:@"myapp:"];  

[[UIApplication sharedApplication] openURL:url];  

3.打开之后,会调用appA的AppDelegate的

- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {}

4.判断是否能打开应用

[[UIApplication sharedApplication] canOpenURL:[NSURLURLWithString:@"myapp://"]];