调用者:
只需要执行以下调用方法,以“://”为分隔符,左边就是要调用APP的地址,右边是你要传给这个APP的参数。
NSURL *url = [NSURL URLWithString:@"Ceshi001://aaaaaaa"]; [[UIApplication sharedApplication] openURL:url];
被调用者:
info.plist文件中添加URL types属性,如下图所示:
并实现以下委托方法
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { NSString*text=[[url host]stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSLog(@"%@",text); NSLog(@"%@",url.description); NSLog(@"%@",sourceApplication); return YES; }
打印信息如下:
015-05-26 15:26:00.821 HAppTest[5365:1695127] aaaaaaa
2015-05-26 15:26:00.822 HAppTest[5365:1695127] Ceshi001://aaaaaaa
2015-05-26 15:26:00.822 HAppTest[5365:1695127] com.huaxun.AppTest
时间: 2024-10-17 00:30:27