gpt4 book ai didi

ios - Applinks iOS URL 导航

转载 作者:行者123 更新时间:2023-11-29 02:58:23 26 4
gpt4 key购买 nike

我正在尝试创建一个利用应用程序链接的应用程序。也就是说,我想从我自己的应用程序导航到其他 iOS 应用程序。我已经安装了 Bolt 框架并正在使用 [BFAppLinkNavigation navigatorToURLInBackground:url];导航到网页。我似乎无法直接链接到我手机上安装的应用程序。我相信这是因为我不知道当前要传入的 URL 是什么。

如果有人可以建议在哪里找到可以引导我使用 AppLinks 访问应用程序的 URL,我们将不胜感激。

提前致谢!

最佳答案

看起来像这样:

NSString *html = [self htmlWithMetaTags:@[
@{
@"al:ios": [NSNull null],
@"al:ios:url": @"bolts://",
@"al:ios:app_name": @"Bolts",
@"al:ios:app_store_id": @"12345"
}
]];
NSURL *url = [self dataUrlForHtml:html];

[BFAppLinkNavigation navigateToURLInBackground:url];

下面还需要三个自定义函数:

- (NSString *)htmlWithMetaTags:(NSArray *)tags {
NSMutableString *html = [NSMutableString stringWithString:@"<html><head>"];

for (NSDictionary *dict in tags) {
for (NSString *key in dict) {
if (dict[key] == [NSNull null]) {
[html appendFormat:@"<meta property=\"%@\">", key];
} else {
[html appendFormat:@"<meta property=\"%@\" content=\"%@\">", key, dict[key]];
}
}
}

[html appendString:@"</head><body>Hello, world!</body></html>"];
NSLog(@"html:%@",html);
return html;
}

- (NSURL *)dataUrlForHtml:(NSString *)html {
NSString *encoded = [self stringByEscapingQueryString:html];
NSString *urlString = [NSString stringWithFormat:@"data:text/html,%@", encoded];
return [NSURL URLWithString:urlString];
}

- (NSString *)stringByEscapingQueryString:(NSString *)string {
return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL,(CFStringRef)string,NULL,(CFStringRef)@":/?#[]@!$&'()*+,;=",kCFStringEncodingUTF8));
}

您可以在 BoltsTests 中找到以上所有内容。 http://applinks.org/documentation/

关于ios - Applinks iOS URL 导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23600457/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com