Thursday, 30 November 2017

How To Implement Deep Linking on iOS



There are surely commonly when your association would need to empower profound connecting. Let's assume you need to partner or pass certain duties then onto the next application, or you have constructed a suite of utility applications starting with you need to coordinate a client starting with one application then onto the next application, going in particular data in a logically delicate manner.
 Possibly you need to empower clients to explore from a contact in your application specifically to his or her LinkedIn profile. Without a doubt, you could simply give a URL, yet that would raise a program with the Web variant of the application rather than the local LinkedIn application. With profound connecting, designers can set up applications so they logically divert a client to an exact area in another application. This is done through the wrapping of a Uniform Resource Identifier (URI) that weds a certain area address, designed like:

facebook://profile/programmableweb

The thought is to embody indispensable data in an ascertained and purposeful approach to permit outer applications (or even Web pages) to open up another local application and present the particular area inside the application that the URI alludes to. This relevant arrangement gives a path around the shut environment in stages like iOS, and more noteworthy cross-application mix.

Android has upheld profound connecting for a long while, and Android's Chrome program list items even profound connect to certain applications.

Application Links By Facebook

Application Links is a profound connecting standard by Facebook that superseeds the organization's expostulated Deep Linking with iOS. Increasing wide group consideration on account of the sponsorship of Facebook, App Links takes into account content, regardless of whether in a Facebook Feed or another App Links-empowered application, to hop specifically to a particular area inside the application.

The above delineates the work process, whereby a man for example would see your substance on a Facebook channel (or another application or even a Web page), which has a given App Link meta-information.

1.            The client chooses the App Link meta-information;

2.            Facebook looks into the substance (or, on the off chance that it is a site page, including some additional metadata) and figures out what application ought to be propelled through a registry Facebook keeps up for open web urls.

3.            Facebook at that point dispatches your application with the logical information added (i.e., particular profile or some other area data) to stack content specifically. On the off chance that the client has not introduced your application, it would then load a Web page.

Beginning with AppLinks

For our case we will allude to an AppLink from one of our Web pages that we have. Along these lines, inside the header, an imaginary ProgrammableWeb application, we would enlist in the header the meta information as takes after:

<head>

<meta property="al:ios:url" content="programmableweb://news/1331"/>

<meta property="al:ios:app_store_id" content="44492821"/>

<meta property="al:ios:app_name" content="PPW for iOS App"/>

<meta property="og:title" content="ProgrammableWeb News"/>

</head>

In the main line above, you can see we are alluding to a particular connection:

programmableweb://news/1331

Inside our invented iOS application, we would have characterized the url in the .plist record, yet in the event that the client hasn't introduced the application, it would fall back to the url/news/1311, which was gotten from the programmableweb://news/1331 meta-information.

For the individuals who don't have a site with Web substance, and subsequently open Web URLs, there is the alternative of utilizing Facebook's Mobile Hosting API. This enables clients to deal with your App Links; you can begin on iOS by entering the accompanying into twist (in terminal):

twist https://graph.facebook.com/application/app_link_hosts \

- F access_token="APP_ACCESS_TOKEN" \

- F name="ProgrammableWeb for iOS Example" \

- F ios=' [

{

"url" : "programmableweb://news/1331",

"app_store_id" : 44492821,

"app_name" : "PPW for iOS App",

},

]' \

- F web=' {

"should_fallback" : false,

}'

We would recover an id returned in JSON design:

{"id":"xxxx1234"}

You can in this manner recover your new App Links URI through another twist ask for, by going in the id returned in the past advance:

twist - G https://graph.facebook.com/xxxx1234 \

- d access_token="APP_ACCESS_TOKEN" \

- d fields=canonical_url \

- d pretty=true

There's one cool advantage worth specifying: the capacity to modify the fallback to divert clients to the App Store to download your application in the event that they haven't introduced your application and have chosen the profound connection. The client would then get coordinated to the suitable profound connection, with the substance go in, not breaking the engagement chain of occasions.

Your application would get a JSON-encoded information bundle like the accompanying:

{

"target_url": "https://www.example.com/abc.html",

"additional items": {

"fb_app_id": [YOUR_FACEBOOK_APP_ID],

"fb_access_token": "[ACCESS_TOKEN']",

"fb_expires_in": "3600"

},

"referer_app_link": {

"url": "[FACEBOOK_APP_BACK_LINK]",

"app_name": "Facebook"

}

}

You at that point supersede in your AppDelegate class, the application:openURL:sourceApplication:annotation: technique to tweak how you handle the parsed approaching App Link ask. We suggest utilizing for iOS the low-level Bolts Library Framework, which will help with receptive and occasion driven demand administration.

- (BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication

annotation:(id)annotation {

return [FBAppCall handleOpenURL:url

sourceApplication:sourceApplication

fallbackHandler:^(FBAppCall *call) {

BFURL *parsedUrl = [BFURL URLWithInboundURL:url sourceApplication:sourceApplication];

on the off chance that ([parsedUrl appLinkData]) {

/this is an applink url, handle it here

NSURL *targetUrl = [parsedUrl targetURL];

[[[UIAlertView alloc] initWithTitle:@"Received interface:"

message:[targetUrl absoluteString]

delegate:nil

cancelButtonTitle:@"OK"

otherButtonTitles:nil] show];

}

}];

}


No comments:

Post a Comment