首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Applinks iOS网址导航

Applinks iOS网址导航
EN

Stack Overflow用户
提问于 2014-05-12 11:07:22
回答 2查看 1.5K关注 0票数 0

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

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

提前感谢!

EN

回答 2

Stack Overflow用户

发布于 2014-05-20 18:16:18

它看起来是这样的:

代码语言:javascript
复制
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];

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

代码语言:javascript
复制
- (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/

票数 1
EN

Stack Overflow用户

发布于 2014-05-12 12:51:07

这可以通过在你的应用程序中实现URL方案来实现,这也要求你想要导航的其他应用程序必须有该实现,你可以参见下面链接中的教程。

链接:http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes--mobile-6629

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23600457

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档