作各大平臺分享的時候因爲帳號混亂,致使分享回調的時候啓動了另外一個app,這個時候我在猜測這些SDK是怎麼喚醒沒有啓動的其餘app的,不難想象,確定跟AppDelegate處理回調openUrl有關,因而搜了一下才發現,一個應用程序能夠喚醒另外一個應用程序,只怪我菜,好啦,如今告訴不知道的朋友怎麼來實現一個app怎麼喚醒另外一個app,以及讓兩個app之間互相通訊。。。html
-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url數組
{app
if ([[url scheme] isEqualToString:@"achao"])ide
{測試
NSLog(@"%@",url);url
}spa
return YES;htm
}blog
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"achao://hello"]];字符串
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
if ([sourceApplication isEqualToString:@"AC.achao.com"])
{
NSLog(@"%@", sourceApplication); //來源於哪一個app(Bundle identifier)
NSLog(@"scheme:%@", [url scheme]); //url scheme
NSLog(@"query: %@", [url query]); //查詢串 用「?...」格式訪問
return YES;
}
else
return NO;
}
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"achao://hello?name=achao-AC"]];
咱們也能夠直接在safari離輸入"achao://hello?name=achao-AC"來訪問咱們的app1,這個時候sourceApplication就是@"com.apple.mobilesafari"
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.baidu.com"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"sms://158********"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://158********"]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://362****@qq.com"]];
咱們用過不少,估計也是程序內部設置了相似的url scheme來供其餘應用程序操做的