A應(yīng)用跳轉(zhuǎn)到B應(yīng)用
如下圖在B應(yīng)用項(xiàng)目中設(shè)置了URL Schemes, UrlTyps 是一個(gè)數(shù)組洲敢,可以設(shè)置多個(gè)Schemes,具體值可以隨便寫
image.png
在A應(yīng)用設(shè)置白名單,允許A應(yīng)用跳轉(zhuǎn)到B
info.plist - LSApplicationQueriesSchemes 中添加B應(yīng)用的Schemes
一定要添加否則[UIApplication sharedApplication] canOpenURL:] 是否
image.png
//通過以下方式跳轉(zhuǎn)
NSURL *appUrl = [NSURL URLWithString:@"hhhBApp://BApp"];
if ([[UIApplication sharedApplication] canOpenURL:appUrl]) {
[[UIApplication sharedApplication] openURL:appUrl options:@{} completionHandler:^(BOOL success) {
if (success) {
}
}];
} else {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"未安裝APP" 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從那個(gè)應(yīng)用跳轉(zhuǎn)過來
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
if ([url.absoluteString containsString:@"hhhBApp"]) {
//此處可判斷app從哪里跳轉(zhuǎn)過來
}
return YES;
}