程序员iOS Developer

iOS APP之间的相互跳转

2017-12-13  本文已影响41人  MMD_
APP跳转应用场景

比如现在普及的第三方登录分享地图导航,都需要跳转到指定的APP;

那么问题来了,那么我们如何实现应用间的相互跳转呢?

应用A跳转到应用B

代码事先块

- (void)awakeOtherApp
{
    NSURL *url = [NSURL URLWithString:@"xxxxxx://"];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        [[UIApplication sharedApplication] openURL:url];
    }
    else{
        NSLog(@"没有安装应用");
    }
}
跳转监听

跳转的应用Test的AppDelegate监听其代理方法
9.0后用这个方法

-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{

NSLog(@"url:%@",url.absoluteString);
NSLog(@"host:%@",url.host);
if ([url.host isEqualToString:@"test"])
{
NSLog(@"进入测试界面");
}
return YES;
}

9.0以前用下面的方法

application:openURL:options:
上一篇 下一篇

猜你喜欢

热点阅读