当在在Appdelegate.m中有 多个handleopenURL,我们该如何区分,这里有2种方法
1.判断url的前缀即可,每个SDK的前缀是独一无二的, 可以打印url获取
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
NSLog(@"%@", [url absoluteString]);
if ([string hasPrefix:@“FirstAppURLScheme"]) {
return [WeiboSDK handleOpenURL:url delegate:self];
}else if ([string hasPrefix:@“SecondAppURLScheme"){
return [WXApi handleOpenURL:url delegate:self];
}
return NO;
}}
2.判断url的host,与上面的类似,只是方式不一样
NSString *string =[url absoluteString];
if ([[url host] isEqualToString:@“FirstAppURLScheme"]) {
return [WeiboSDK handleOpenURL:url delegate:self];
}else if ([[url host] isEqualToString:@“SecondAppURLScheme"]){
return [SinaSDK handleOpenURL:url delegate:self];
}
return [WeiboSDK handleOpenURL:url delegate:self];
}else if ([[url host] isEqualToString:@“SecondAppURLScheme"]){
return [SinaSDK handleOpenURL:url delegate:self];
}