Skip to main content
Build the future with Agentforce at TDX in San Francisco or on Salesforce+ on March 5–6. Register now.

Create Universal Links for iOS

Learning Objectives

After completing this unit, you’ll be able to:

  • Implement an iOS Universal Link.
  • Test your iOS Universal Links.
  • Exclude links from your iOS Universal Link implementation.

Marketing Cloud Engagement implements iOS Universal Links as a tenant-wide feature, but it also requires enablement within your mobile app. Fortunately, Pia can work with NTO’s app developers to get all of these changes accomplished with very little effort. Let’s take a look as she starts with app development, then moves into configuring her Marketing Cloud Engagement tenant. 

In this module, we assume you are a Marketing Cloud Engagement admin with the proper permissions and access to create deep links. If you can’t access these features, that’s OK. Read along to learn how Pia would take the steps in a production org. Don't try to follow these steps in your Trailhead Playground. Marketing Cloud Engagement isn't available in the Trailhead Playground.

Remember when we mentioned you’d need an SAP and SSL certificate for the click domain? This step is where that information becomes crucial. Pia talks to the NTO app developers about including the branded click domain link entry in the com.apple.developer.associated-domains entitlement. The entry looks something like this example.

"applinks:click.example.com"

The developers also have to modify the webpageURL property on the NSUserActivity object (provided by iOS) to receive URLs like the following example and determine if they come from the correct click domain.

https://click.example.com/?qs=hxdwbvpwueDMUFuWaNEhguEVdMLWCPTsutky0fd

The developers add a GET request  to unwrap the URL and send the customer to the correct location. Because NTO uses Einstein Content Selection to provide individualized product selections to their subscribers, the developers must also include a GET request for possible Einstein URLs as well.

https://ecs.us.sfmc-einstein.com/einstein/api/block/44644947...

After unwrapping the URL and retrieving the destination, the developers write code to help them resolve the final URL and where they need to take the customer. They draw out code to help resolve all the links and it looks something like this.

Note

We provide this pseudo-code as a model. Each mobile app requires its own code to function specifically with your unique needs.

public func application(_ application: UIApplication,
       continue userActivity: NSUserActivity,
       restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
// Example: Double wrapped url
  if let url = userActivity.webpageURL {
    if url.absoluteString.contains("sfmc-einstein") {
      Networking.getUnwrapped(url) { result in
        switch result {
        case .success(let singleUnwrappedURL):
          // first unwrapped link; will need to be unwrapped again
          Networking.getUnwrapped(singleUnwrappedURL) { result in
            switch result {
            case .success(let doubleUnwrappedURL):
              // Final unwrapped link to be parsed by app
              parseAndRedirect(with: doubleUnwrappedURL)
            case .failure:
              print("Failed to get 2nd unwrapped link")
            }
          }
        case .failure:
          print("Failed to get 1st unwrapped link")
        }
      }
    }
  }
  return true
}

The code for this process directs the message to the correct location, as illustrated in the following figure.

Flowchart presents the path of a clicked link being evaluated for AASA, thenopening in either the app or the browser

Complete the Settings in Email Studio

Pia then logs into Marketing Cloud Engagement and configures the account for use with iOS Universal Links.

  1. In Marketing Cloud Engagement, Pia navigates to Email Studio and clicks the Admin tab.
  2. She clicks Send Management and selects Deep Linking.
  3. She clicks Create.
  4. Pia enters the AppID value (the application's alphanumeric teamID) followed by the bundleID.
  5. She leaves the Type dropdown on iOS.
  6. She forces a mobile web experience for Marketing Cloud Engagement profile and subscription centers by selecting Exclude Profile and Unsub Center.
  7. She saves the entry.

iOS deep linking application details displaying AppID field, Type dropdown, and Exclude Profile and Unsub Center checkbox

This process saves and hosts an apple-app-site-association file on your subdomain, like: https://click.example.com/.well-known/apple-app-site-association. The actual file looks something like this.

{
  "applinks": {
    "apps": [],
    "details": [
    {
      "appID": "ABC123EFG.com.staging.app",
      "paths": [
        "NOT /subscription_center.aspx*",
        "NOT /profile_center.aspx*",
        "NOT /unsub_center.aspx*",
        "NOT /u/*",
        "/*"
      ]
    },
    {
      "appID": "HJK456LMN.com.production.app",
      "paths": [
        "NOT /subscription_center.aspx*",
        "NOT /profile_center.aspx*",
        "NOT /unsub_center.aspx*",
        "NOT /u/*",
        "/*"
      ]
    }
    ]
  }
}

From here, Pia can test the implementation of iOS Universal Links. She adds the domain to the iOS application entitlement and gets to work by sending email messages using iOS Universal Links to development versions of the NTO app.

Note

Using the same click domain for development and production versions doesn’t allow differentiation between test data and production data.

Now, here’s an important note. iOS Universal Links forces your Marketing Cloud Engagement account to think all links open in the mobile app. To make sure that she doesn’t direct specific links to the mobile app, Pia alerts her team to include a string in non-app links for their email messages.

  1. Pia asks the team to open the HTML version of the email message containing the link.
  2. Her team adds mc-deep-link="false" to the <a> tag of the link, like <a href="https://www.example.com" mc-deep-link="false">Your Link</a>.
  3. Finally, they save the email message.

Pia has the iOS side of deep linking covered with this feature. In the next unit, she tackles Android implementation.

Resources 

Condividi il tuo feedback su Trailhead dalla Guida di Salesforce.

Conoscere la tua esperienza su Trailhead è importante per noi. Ora puoi accedere al modulo per l'invio di feedback in qualsiasi momento dal sito della Guida di Salesforce.

Scopri di più Continua a condividere il tuo feedback