1. 添加 项目的 Scheme URL(自定义)
在info.plist文件里面
2.和前端h5制定协议
(1)需求是想要将分享的html内容点击一个跳转后返回app里面详情页;
(2)和前端制定协议 (Scheme URL) + :// + 自定义页面标识符合 + ? + 参数
例如:(demoscheme://descpage?id=123&type=1)
3.h5实现代码
html实现效果上如果iPhone手机安装了app 跳转到详情页,未安装跳到商城
4.在AppDelegate里面实现回调触发事件
- ( BOOL )application:( UIApplication *)app openURL:( NSURL *)url options:( NSDictionary < NSString *, id > *)options
{
if ([url.absoluteString containsString:@"descpage"]) {//与DemoA约定好的字符
if ([self.window.rootViewController isMemberOfClass:[MainTabBarViewController class]]) {
MainTabBarViewController *tab = (MainTabBarViewController *)self.window.rootViewController;
// 2.获得主控制器
BaseNavigationController *rootNav = tab.selectedViewController;
// 3.每次跳转前必须是在跟控制器(细节)
NSString * cur_id= [url.absoluteString stringByReplacingOccurrencesOfString:@"demoscheme://descpage?" withString:@""];
NSLog(@"3jump_url %@",cur_id);
HomeDesController *page = [[HomeDesController alloc] init];
page.cur_id = cur_id;
page.from_vc_name = @"tab";
[rootNav pushViewController:page animated:YES];
}
}
return YES ;
}