Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 2.51 KB

IOS_UNIVERSAL_LINKS.md

File metadata and controls

41 lines (28 loc) · 2.51 KB

🔍 Enabling universal links

  • Ensure you have added the Associated Domains Entitlement to your app in the Capabilities/Associated Domains, e.g.: applinks:yourdomain.com and webcredentials:yourdomain.com.
  • Ensure you have set up the Apple App Site Association file on your website appropriately configured according to the Apple's documentation.

Once the setup is completed, opening the universal link should open your app.

NOTE: Easiest way to test the integration is to send yourself an email containing the Universal link and open it in your email client in a web browser. Universal links work correctly when a user taps <a href= "..."> that will drive the user to another domain. Pasting the URL into Safari won't work. Neither does following the link on the same domain or opening the URL with Javascript.

🔍 Tracking universal links

Update your app's App Delegate to respond to the universal link.

When iOS opens your app due to a universal link, your app receives an NSUserActivity object with an activityType value of NSUserActivityTypeBrowsingWeb. The activity object's webpageURL property contains the URL that needs to be passed on to the Exponea SDK's ExponeaLinkHandler's HandleCampaignClick method.

💻 Example

 public override bool ContinueUserActivity(UIApplication application, NSUserActivity userActivity, UIApplicationRestorationHandler completionHandler)
        {
            if (userActivity.ActivityType == "NSUserActivityTypeBrowsingWeb" && userActivity.WebPageUrl != null) 
            {
                ExponeaLinkHandler.Instance.HandleCampaignClick(userActivity.WebPageUrl);
                return userActivity.WebPageUrl.Host == "yourdomain.com";
            }

            return false;
        }

        public override bool OpenUrl(UIApplication app, NSUrl url, NSDictionary options)
        {
            ExponeaLinkHandler.Instance.HandleCampaignClick(url);
            return base.OpenUrl(app, url, options);
        }

When an iOS app is loaded from a Universal Link, you can override the ContinueUserActivity in AppDelegate.cs to get the URL passed. From here, you can move around in your app as needed.

If your app is not running, OpenUrl method will be called instead.

NOTE: Exponea SDK might not be configured when HandleCampaignClick is called. In this case, the event will be sent to Exponea servers after SDK is configured.