{"_id":"5ab565f112d24900747242a5","category":{"_id":"5ab565f112d249007472429a","version":"5ab565f112d2490074724298","project":"57c88b374434350e00509d7f","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-09-30T22:04:21.938Z","from_sync":false,"order":1,"slug":"guides","title":"Guides"},"project":"57c88b374434350e00509d7f","user":"55e5ba046015ce1900eadb8e","parentDoc":null,"version":{"_id":"5ab565f112d2490074724298","project":"57c88b374434350e00509d7f","__v":1,"createdAt":"2018-03-23T20:39:13.299Z","releaseDate":"2018-03-23T20:39:13.299Z","categories":["5ab565f112d2490074724299","5ab565f112d249007472429a","5ab565f112d249007472429b","5ab565f112d249007472429c"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"3.6.0","version":"3.6.0"},"githubsync":"","__v":0,"updates":["57472abe7e1a410e004cc80f"],"next":{"pages":[],"description":""},"createdAt":"2016-05-25T08:23:26.511Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"Follow this quick guide to learn how to set Universal Links up for your app and start using them with Primer!\nAt the end of the guide you'll have Primer Smart Links opening your installed app immediately.\n\nBefore getting started, make sure you have the [Primer iOS SDK integrated](doc:quick-start).\n\n1. [Turn on Universal Links on the Dashboard](#1-turn-on-universal-links-on-the-dashboard)\n2. [Add the Associated Domains entitlement](#2-add-the-associated-domains-entitlement)\n3. [Handle incoming User Activities](#3-handle-incoming-user-activities)\n4. [Test in your app](#4-test-in-your-app)\n\nNeed help or have questions? Don't hesitate to [Contact Us](doc:contact-us)!\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"1. Turn on Universal Links on the Dashboard\"\n}\n[/block]\nGo to the App Store URLs tab in your <a href=\"http://goprimer.com/dashboard#/project//edit?tab=appStoreURLs\" target=\"_blank\">Project Settings</a>. Check the box to `Enable Universal Links`, and put in your application's Bundle ID, then your Apple Team ID. Once done, just hit the `Save` button. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"You can find your Apple Team ID at the `Membership` page of the <a href=\\\"https://developer.apple.com\\\">Apple Developer Portal</a>.\"\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/Oy0nPRCnTt28zyFZW9ak_universal_links_dashboard.png\",\n        \"universal_links_dashboard.png\",\n        \"1470\",\n        \"734\",\n        \"#3da6b5\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Add the Associated Domains entitlement\"\n}\n[/block]\nNow go back to the <a href=\"https://developer.apple.com\">Apple Developer Portal</a>, and navigate to your `App IDs`. Make sure that your application's ID has the Associated Domains service enabled. If it's not yet turned on, just expand the row of your App ID, and click the `Edit` button. Then check the box to enable Associated Domains, and hit `Save`.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/nUvhRzhwQeuSBTWDIOXc_universal_links_developer.png\",\n        \"universal_links_developer.png\",\n        \"1470\",\n        \"734\",\n        \"#31af6c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nOpen your project's settings in Xcode, select the app's target, and go to the `Capabilities` tab. Find the `Associated Domains` section, and turn on its switch. Add `applinks:getapp.in` to the Domains table, and make sure that the steps are checked out and gray. (If not yet, Xcode provides a `Fix Issues` button right in place to automatically solve any related setup issues.)\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/qV3YBH9R0eySVMvNpjCR_universal_links_xcode.png\",\n        \"universal_links_xcode.png\",\n        \"1470\",\n        \"734\",\n        \"#153c6c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nNow find and select the `[yourprojectname].entitlements` file in the Xcode Project Navigator on the left side, and ensure that your app's build target is checked in the right sidebar.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Handle incoming User Activities\"\n}\n[/block]\nEnsure that the `-application:continueUserActivity:restorationHandler:` method is implemented in your application's delegate, and let Primer handle any incoming User Activities.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {\\n    BOOL handled = [Primer continueUserActivity:userActivity];\\n    return handled;\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: :::at:::escaping ([Any]?) -> Void) -> Bool {\\n    let handled = Primer.continue(userActivity)\\n    return handled\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Test in your app\"\n}\n[/block]\nIf you completed all the steps above you can install a new build on your device, and test that Universal Links are working with Primer. Just create a new Smart Link (or use an already existing one), and open it on your device in Mail, Messages, or Notes. If your integration was successful your app should open immediately, without opening Safari first.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"You're done!\"\n}\n[/block]\nGreat work! You've just successfully set up Universal Links to work with Primer!\n\nFrom here you can start using it with Smart Links containing deep links into your application, and open opening the app this way Primer will open the given deep link. To learn more about Smart Links take a look at the [Attribution](doc:attribution) reference page.","excerpt":"","slug":"universal-links-guide","type":"basic","title":"Universal Links Guide"}

Universal Links Guide


Follow this quick guide to learn how to set Universal Links up for your app and start using them with Primer! At the end of the guide you'll have Primer Smart Links opening your installed app immediately. Before getting started, make sure you have the [Primer iOS SDK integrated](doc:quick-start). 1. [Turn on Universal Links on the Dashboard](#1-turn-on-universal-links-on-the-dashboard) 2. [Add the Associated Domains entitlement](#2-add-the-associated-domains-entitlement) 3. [Handle incoming User Activities](#3-handle-incoming-user-activities) 4. [Test in your app](#4-test-in-your-app) Need help or have questions? Don't hesitate to [Contact Us](doc:contact-us)! [block:api-header] { "type": "basic", "title": "1. Turn on Universal Links on the Dashboard" } [/block] Go to the App Store URLs tab in your <a href="http://goprimer.com/dashboard#/project//edit?tab=appStoreURLs" target="_blank">Project Settings</a>. Check the box to `Enable Universal Links`, and put in your application's Bundle ID, then your Apple Team ID. Once done, just hit the `Save` button. [block:callout] { "type": "info", "body": "You can find your Apple Team ID at the `Membership` page of the <a href=\"https://developer.apple.com\">Apple Developer Portal</a>." } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/Oy0nPRCnTt28zyFZW9ak_universal_links_dashboard.png", "universal_links_dashboard.png", "1470", "734", "#3da6b5", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "2. Add the Associated Domains entitlement" } [/block] Now go back to the <a href="https://developer.apple.com">Apple Developer Portal</a>, and navigate to your `App IDs`. Make sure that your application's ID has the Associated Domains service enabled. If it's not yet turned on, just expand the row of your App ID, and click the `Edit` button. Then check the box to enable Associated Domains, and hit `Save`. [block:image] { "images": [ { "image": [ "https://files.readme.io/nUvhRzhwQeuSBTWDIOXc_universal_links_developer.png", "universal_links_developer.png", "1470", "734", "#31af6c", "" ] } ] } [/block] Open your project's settings in Xcode, select the app's target, and go to the `Capabilities` tab. Find the `Associated Domains` section, and turn on its switch. Add `applinks:getapp.in` to the Domains table, and make sure that the steps are checked out and gray. (If not yet, Xcode provides a `Fix Issues` button right in place to automatically solve any related setup issues.) [block:image] { "images": [ { "image": [ "https://files.readme.io/qV3YBH9R0eySVMvNpjCR_universal_links_xcode.png", "universal_links_xcode.png", "1470", "734", "#153c6c", "" ] } ] } [/block] Now find and select the `[yourprojectname].entitlements` file in the Xcode Project Navigator on the left side, and ensure that your app's build target is checked in the right sidebar. [block:api-header] { "type": "basic", "title": "3. Handle incoming User Activities" } [/block] Ensure that the `-application:continueUserActivity:restorationHandler:` method is implemented in your application's delegate, and let Primer handle any incoming User Activities. [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler {\n BOOL handled = [Primer continueUserActivity:userActivity];\n return handled;\n}", "language": "objectivec" }, { "code": "func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {\n let handled = Primer.continue(userActivity)\n return handled\n}", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Test in your app" } [/block] If you completed all the steps above you can install a new build on your device, and test that Universal Links are working with Primer. Just create a new Smart Link (or use an already existing one), and open it on your device in Mail, Messages, or Notes. If your integration was successful your app should open immediately, without opening Safari first. [block:api-header] { "type": "basic", "title": "You're done!" } [/block] Great work! You've just successfully set up Universal Links to work with Primer! From here you can start using it with Smart Links containing deep links into your application, and open opening the app this way Primer will open the given deep link. To learn more about Smart Links take a look at the [Attribution](doc:attribution) reference page.