調用者:
只需要執行以下調用方法,以“://”為分隔符,左邊就是要調用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