It looks like this :
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];
And still need three custom functions below:
- (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));
}
You can find all above in BoltsTests. http://applinks.org/documentation/