1、MyApp、AimApp设置
2、现在就可进行跳转了
MyApp 跳转 AimApp,在MyApp中添加以下代码
NSString *paramStr = [NSString stringWithFormat:@"AimApp://key1=%@&key2=%@&key3=%@", value1, value2, value3];
//防止出现中文,进行转码
paramStr = [paramStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:paramStr];
[[UIApplication sharedApplication] openURL:url];
AimApp中接收数据
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
NSString *urlStr = [url absoluteString];
if ([urlStr hasPrefix:@"AimApp://"]) {
NSLog(@"MyApp request params: %@", urlStr);
urlStr = [urlStr stringByReplacingOccurrencesOfString:@"AimApp://" withString:@""];
NSArray *paramArray = [urlStr componentsSeparatedByString:@"&"];
NSLog(@"paramArray: %@", paramArray);
NSMutableDictionary *paramsDic = [[NSMutableDictionary alloc] initWithCapacity:0];
for (int i = 0; i < paramArray.count; i++) {
NSString *str = paramArray[i];
NSArray *keyArray = [str componentsSeparatedByString:@"="];
NSString *key = keyArray[0];
NSString *value = keyArray[1];
[paramsDic setObject:value forKey:key];
NSLog(@"key:%@ ==== value:%@", key, value);
}
}
return NO;
}
AimApp 跳转 MyApp 同样的设置,只是修改一下AimApp://
,接收的时候判断是否是MyApp://
开头就好。