我正在尝试创建一个使用applinks的应用程序。也就是说,我想从我自己的应用程序导航到其他iOS应用程序。我已经安装了Bolt框架,并且正在使用[BFAppLinkNavigation navigateToURLInBackground:url];导航到网页。我似乎无法直接链接到我在手机上安装的应用程序。我相信这是因为我不知道当前传入的URL是什么。
如果任何人可以建议在哪里找到URL,将引导我使用AppLinks的应用程序,将不胜感激。
提前感谢!
发布于 2014-05-20 18:16:18
它看起来是这样的:
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/
发布于 2014-05-12 12:51:07
这可以通过在你的应用程序中实现URL方案来实现,这也要求你想要导航的其他应用程序必须有该实现,你可以参见下面链接中的教程。
链接:http://code.tutsplus.com/tutorials/ios-sdk-working-with-url-schemes--mobile-6629
https://stackoverflow.com/questions/23600457
复制相似问题