标签:ios1 nsurl amp val oid 传参 orm map handle
app 之间跳转和传参;
首先 创建2个app formApp (需要跳转到另外app的项目) toApp(被跳转的项目)
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options { /** 如果使用URL 传参数 */ NSLog(@"----formApp_URL:%@",url); /** 如果使用的是剪切板传参的话, */ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; NSString *content = pasteboard.string; NSLog(@"剪切板获取参数:%@",content); /** 其他操作 */ return YES; }
/** 跳转操作 */ - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { /** toApp Schemes:// */ NSString *toAppSchemes = @"willToAppURLSchemes://"; /** 检测设备 是否安装toApp */ if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:toAppSchemes]]) { NSLog(@"alearly install"); /** 跳转app */ /** 1:使用URL 传递参数 */ if ([self IOS10]) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?usrid=110",toAppSchemes]] options:@{} completionHandler:^(BOOL success) { /** 成功跳转后的操作 */ }]; }else{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?usrid=110",toAppSchemes]]]; } // /** // 2:使用剪切板传递参数 // */ // [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:toAppSchemes]]; // /** // 系统剪切板 (在topApp中 接受到参数后,清空) // */ // UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; // pasteboard.string = @"user=120&orderid=123456"; }else{ NSLog(@"not install"); } } /** 判断 系统是否 大于10 */ - (BOOL)IOS10 { return ([[[UIDevice currentDevice] systemVersion] floatValue]) >= 10 ? YES : NO; }
打开formApp info.plist文件,添加 LSApplicationQueriesSchemes
这样就可以成功检测到 是否安装toApp了,
标签:ios1 nsurl amp val oid 传参 orm map handle
原文地址:http://www.cnblogs.com/liuwenqiang/p/6882910.html