Tapstream

Turn Your Tapstream Links into iOS Universal Links in 3 Easy Steps

When Apple released iOS 9.2 in December, it drew a pretty clear line in the sand with respect to how it wants you to implement deep linking in your apps. Until iOS 9.2 it was easy enough to redirect a URL through mobile Safari through to an app…The app registers its URL scheme (eg. Twitter:// , Facebook:// , etc) with the operating system and anytime the OS received a request for a registered scheme, it would open up the app on the device (if installed). With iOS 9.2, Apple removed this capability in mobile Safari and now trying to redirect to a deep link gets you a Safari error message.

The days of custom URL schemes  are coming to an end. Apple now wants you to move towards supporting Universal Links.

If you’re not familiar with Universal Links, have a read here, here, and here. This post won’t cover what they are, rather we’ll show you how to imbue your Tapstream links with Universal Link super powers.

1) Configure team and bundle ID’s

Head on over to http://developer.apple.com and log into your account. Find the appropriate app ID and make note of your team prefix and bundle ID. Also, make sure you have Associated Domains enabled.

Now head back to your Tapstream account, and find the account configuration item from the settings menu:

On the account config page, scroll down until you find the section Apple Bundle Identifiers and add your team and bundle ids here. Don’t forget to save the settings at the bottom.

2) Add entitlement to Xcode

Now open up your project in Xcode and on the capabilities tab, find Associated Domains and enter applinks:taps.io

3) Implement UL handling in your app

Universal Links are handled by adding an application:continueUserActivity:restorationHandler  method to your AppDelegate. In this method, you’ll need to pass the userActivity  on to Tapstream’s handleUniversalLink  method. This is required for Tapstream to record the user visiting the link, since universal links override our usual redirectors.

handleUniversalLink  returns a TSUniversalLink  object (available from TSUniversalLink.h ), which exposes 3 properties: deeplinkURL , fallbackURL , and status .

Status is a TSUniversalLinkStatus  enum, which can have three values:

kTSULValid  means that the link was recognized by Tapstream. At least one of the fallbackUrl  or deeplinkUrl  properties will be present.
kTSULDisabled  means that the link is valid, but the campaign has disabled Universal Link support.
kTSULUnknown  means that Tapstream did not recognize the link.
For most integrations, it is appropriate to simply check that the status is kTSULValid . If it is, you may parse the deeplinkURL  and/or fallbackURL  and display the relevant content accordingly. The deeplinkURL  will contain a registered URL as defined by your campaign, while the fallbackURL  will contain the fallback URL (i.e., the URL registered with a device type of “ANY”).

In case of an unhandled universal link, you should call openURL  to redirect the user to Safari. An example of this usage:

That’s it. You’re done.

Now head on over to your Tapstream account and create a new campaign link. Remember to turn on / enable UL for the new link:

Important: When testing out the link, make sure you tap on the link and don’t just paste it into the browser address bar. 

ezgif.com-resize

We’ve made implementing Universal Links with your Tapstream links as easy as possible. We do support more complex configurations for custom domains. For complete documentation on using Universal Links with your custom URL’s, please see here: https://tapstream.com/developer/ios-swift/universal-links/