A应用跳转到B应用
如下图在B应用项目中设置了URL Schemes, UrlTyps 是一个数组,可以设置多个Schemes,具体值可以随便写
![](https://img.haomeiwen.com/i1792012/38a12fa920c96458.png)
B应用在info.plist - LSApplicationQueriesSchemes 中添加A应用的Schemes
一定要添加否则[UIApplication sharedApplication] canOpenURL:] 是否
![](https://img.haomeiwen.com/i1792012/5b3c1ed7e7f4caff.png)
//通过以下方式跳转
NSURL *Url = [NSURL URLWithString:@"hhSimple://com.hhAPP"];
// NSURL *Url = [NSURL URLWithString:@"HHChat://com.hhAPP"];
if ([[UIApplication sharedApplication] canOpenURL:Url]) {
[[UIApplication sharedApplication] openURL:Url options:@{} completionHandler:^(BOOL success) {
if (success) {
}
}];
} else {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"未安装皖税通" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}];
[alert addAction:sure];
dispatch_async(dispatch_get_main_queue(), ^{
[self presentViewController:alert animated:YES completion:nil];
});
}
在appDelegate 中,通过此方法判断app从那个应用跳转过来
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
if ([url.absoluteString containsString:@"hhSimple"]) {
//此处可判断app从哪里跳转过来
}
return YES;
}
网友评论