0

I am trying create an application that utilizes applinks. That is, I want to navigate to other iOS applications from my own. I have installed the Bolt framework and am using [BFAppLinkNavigation navigateToURLInBackground:url]; to navigate to webpages. I cannot seem to link straight to an application that I have installed on my phone. I believe this is because I do not know what the current URL to pass in is.

If anyone could advise on where to locate URLs that will lead me to applications using AppLinks, it would be much appreciated.

Thanks in advance!

Sahil Mittal
  • 20,697
  • 12
  • 65
  • 90
Ankush Agrawal
  • 395
  • 2
  • 14

2 Answers2

1

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/

0

This could be achieve by implementing URL Scheme in your application and this also require that the other application on which you want to navigate should have that implementation you can see the tutorial in below link for the same.

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

Kushagra
  • 49
  • 6