1、首先建两个工程,并且在info中分别设置URL Schemes为 testApp1 和 testApp2

在info.plist中分别设置白名单,让app能自由的跳转

2、在appdelegate中添加方法
// 有外部app通过URL Scheme 的方法打开本应用,就会走本应用的这个方法
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
NSString *test = url.host; // 这就是参数
NSLog(@"host = %@",test);
NSLog(@"url = %@", url);
return YES;
}
3、拉个按钮出来,并写出跳转方法
- (IBAction)testTo2 {
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"testApp2://"]]) {
//后跟的是参数
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"testApp2://canshu"]];
}
}
4、over
网友评论