{"_id":"5ab565f112d249007472429f","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"},"parentDoc":null,"project":"57c88b374434350e00509d7f","user":"545a811ebf1d2b0e00aaa1f2","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"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-09-29T00:14:10.560Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"Follow these easy few steps to personalize the onboarding experience for your users. In this example we'll create a customized onboarding flow that shows our profile photo and a custom invite message if the user installs trough a Smart Link.\n\nBefore getting started, make sure you have the [Primer iOS SDK integrated](doc:quick-start).\n\n1. [Build Personalized Onboarding](#1-build-personalized-onboarding)\n2. [Grab the Targeting key](#2-grab-the-targeting-key)\n3. [Generate Smart Links](#3-generate-smart-links)\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. Build Personalized Onboarding\"\n}\n[/block]\nGo to the <a href=\"http://goprimer.com/dashboard\" target=\"_blank\">Dashboard</a> and create a new flow. Set the Targeting to `Shares` and then select a theme. In this example we use `Lounge`. Next, add a referral screen from the theme to your flow and set it as the first screen.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/eK3B0BjOSkqUIthvQJuD_invite_template.png\",\n        \"invite_template.png\",\n        \"1470\",\n        \"734\",\n        \"#ab9454\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nWe'll customize the first screen so that it listens to the correct settings. Select the photo and replace it with a dynamic property based one `profile_pic` with type `Sender`. Additionally, we'll add some dynamically generated properties to the copy. Add `{send.dinner_date}` to the first line and change the second line to say \"RSVP AT `{send.res}`\". *Note: these keys are case sensitive!*\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/aPZm4hgTNqscR54fSQew_invite_edit_screen.png\",\n        \"invite_edit_screen.png\",\n        \"1470\",\n        \"734\",\n        \"#8f544b\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nFinally launch the new flow!\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Grab the Targeting key\"\n}\n[/block]\nNow we need to go grab the targeting key for the iOS SDK to generate Smart Links for this flow. Find your new `Shares` targeting and edit it to bring up the configuration popup. Copy the `TARGETING KEY` for the next step.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/JRmefaGFSPuKgd0RFzTK_invite_targeting.png\",\n        \"invite_targeting.png\",\n        \"1470\",\n        \"734\",\n        \"#409fab\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nIf you havent specified your App Store URL yet, set one either in your <a href=\"http://goprimer.com/dashboard#/project//edit?tab=appStoreURLs\" target=\"_blank\">Project Settings</a> or on the Targeting itself.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/tf6oCZBdTFCifPRHFYvw_invite_url.png\",\n        \"invite_url.png\",\n        \"1470\",\n        \"734\",\n        \"#f83d3d\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Generate Smart Links\"\n}\n[/block]\nThe flow we created above required 3 pieces of dynamic information:\n- the user's profile picture - `profile_pic`,\n- the dinner invitation's date - `dinner_date`,\n- and the dinner invitation's restaurant - `res`.\n\nLet's first set the user's profile photo as a user propertiy on the current user, to make it available on the dashboard under `sender`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"[Primer appendUserProperties::::at:::{@\\\"profile_pic\\\": @\\\"http://cdn.goprimer.com/PrimerDemo/Tian.jpg\\\"}];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"Primer.appendUserProperties([\\\"profile_pic\\\": \\\"http://cdn.goprimer.com/PrimerDemo/Tian.jpg\\\"])\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\nNow, lets generate a Smart Link and send it in a text message!\nThis will try to present a `MFMessageComposeViewController` on the `rootViewController` of your app. You may need to change this to the correct location for it to present from.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <MessageUI/MessageUI.h>\\n\\nNSDictionary *parameters = @{@\\\"res\\\": @\\\"Tim's Steakhouse\\\", @\\\"dinner_date\\\": @\\\"October 25th\\\"};\\n\\n[Primer getLinkForTargeting:@\\\"SHARES\\\" withParameters:parameters completion:^(NSString * _Nullable link) {\\n    // Check if the link is not nil.\\n    if (!link) {\\n        return\\n    }\\n    \\n    // Check if the device supports text messages.\\n    if (![MFMessageComposeViewController canSendText]) {\\n      return\\n    }\\n    \\n    // Create a new compose view controller.\\n    MFMessageComposeViewController *composeVC = [[MFMessageComposeViewController alloc] init];\\n    \\n    // Insert the link into the message.\\n    NSString *messageBody = [NSString stringWithFormat:@\\\"I made us dinner reservations on %@! RSVP here %@\\\", parameters[\\\"dinner_date\\\"], link];\\n    composeVC.body = messageBody;\\n    \\n    // Set the recipient.\\n    composeVC.recipients = @[@\\\"5164679651\\\"];\\n    \\n    // Prompt the user to send the message.\\n    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;\\n    UIViewController *rootVC = appDelegate.window.rootViewController;\\n    [rootVC presentViewController:composeVC animated:YES completion:nil];\\n}];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"import MessageUI\\n\\nlet parameters = [\\\"res\\\": \\\"Tim's Steakhouse\\\", \\\"dinner_date\\\": \\\"October 25th\\\"]\\n\\nPrimer.getLinkForTargeting(\\\"SHARES\\\", withParameters: parameters) { (link: String?) in\\n    \\n    // Check if the link is not nil.\\n    guard (link != nil) else {\\n    \\treturn\\n    }\\n    \\n    // Check if the device supports text messages.\\n    guard MFMessageComposeViewController.canSendText() else {\\n    \\treturn\\n    }\\n    \\n    // Create a new compose view controller.\\n    let composeVC = MFMessageComposeViewController()\\n    \\n    // Insert the link into the message.\\n    let messageBody = String(format:\\\"I made us dinner reservations on %@! RSVP here %@\\\", parameters[\\\"dinner_date\\\"], link!)\\n    composeVC.body = messageBody\\n    \\n    // Set the recipient.\\n    composeVC.recipients = [\\\"5164679651\\\"]\\n    \\n    // Prompt the user to send the message.\\n    let appDelegate = UIApplication.shared.delegate as! AppDelegate\\n    let rootVC = appDelegate.window!.rootViewController!\\n    rootVC.present(composeVC, animated: true, completion: nil)\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"You're Done!\"\n}\n[/block]\nWhen your recipient clicks the link to install the app, they'll see a flow customized just for them!\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/KoBSbwh0R92QoRBDDmmI_invite_final.png\",\n        \"invite_final.png\",\n        \"1470\",\n        \"734\",\n        \"#a08956\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n Check out [Attribution](doc:attribution) for more information regarding Smart Links!","excerpt":"","slug":"invite-links-guide","type":"basic","title":"Invite Links Guide"}

Invite Links Guide


Follow these easy few steps to personalize the onboarding experience for your users. In this example we'll create a customized onboarding flow that shows our profile photo and a custom invite message if the user installs trough a Smart Link. Before getting started, make sure you have the [Primer iOS SDK integrated](doc:quick-start). 1. [Build Personalized Onboarding](#1-build-personalized-onboarding) 2. [Grab the Targeting key](#2-grab-the-targeting-key) 3. [Generate Smart Links](#3-generate-smart-links) Need help or have questions? Don't hesitate to [Contact Us](doc:contact-us)! [block:api-header] { "type": "basic", "title": "1. Build Personalized Onboarding" } [/block] Go to the <a href="http://goprimer.com/dashboard" target="_blank">Dashboard</a> and create a new flow. Set the Targeting to `Shares` and then select a theme. In this example we use `Lounge`. Next, add a referral screen from the theme to your flow and set it as the first screen. [block:image] { "images": [ { "image": [ "https://files.readme.io/eK3B0BjOSkqUIthvQJuD_invite_template.png", "invite_template.png", "1470", "734", "#ab9454", "" ] } ] } [/block] We'll customize the first screen so that it listens to the correct settings. Select the photo and replace it with a dynamic property based one `profile_pic` with type `Sender`. Additionally, we'll add some dynamically generated properties to the copy. Add `{send.dinner_date}` to the first line and change the second line to say "RSVP AT `{send.res}`". *Note: these keys are case sensitive!* [block:image] { "images": [ { "image": [ "https://files.readme.io/aPZm4hgTNqscR54fSQew_invite_edit_screen.png", "invite_edit_screen.png", "1470", "734", "#8f544b", "" ] } ] } [/block] Finally launch the new flow! [block:api-header] { "type": "basic", "title": "2. Grab the Targeting key" } [/block] Now we need to go grab the targeting key for the iOS SDK to generate Smart Links for this flow. Find your new `Shares` targeting and edit it to bring up the configuration popup. Copy the `TARGETING KEY` for the next step. [block:image] { "images": [ { "image": [ "https://files.readme.io/JRmefaGFSPuKgd0RFzTK_invite_targeting.png", "invite_targeting.png", "1470", "734", "#409fab", "" ] } ] } [/block] If you havent specified your App Store URL yet, set one either in your <a href="http://goprimer.com/dashboard#/project//edit?tab=appStoreURLs" target="_blank">Project Settings</a> or on the Targeting itself. [block:image] { "images": [ { "image": [ "https://files.readme.io/tf6oCZBdTFCifPRHFYvw_invite_url.png", "invite_url.png", "1470", "734", "#f83d3d", "" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Generate Smart Links" } [/block] The flow we created above required 3 pieces of dynamic information: - the user's profile picture - `profile_pic`, - the dinner invitation's date - `dinner_date`, - and the dinner invitation's restaurant - `res`. Let's first set the user's profile photo as a user propertiy on the current user, to make it available on the dashboard under `sender`. [block:code] { "codes": [ { "code": "[Primer appendUserProperties:@{@\"profile_pic\": @\"http://cdn.goprimer.com/PrimerDemo/Tian.jpg\"}];", "language": "objectivec" }, { "code": "Primer.appendUserProperties([\"profile_pic\": \"http://cdn.goprimer.com/PrimerDemo/Tian.jpg\"])", "language": "swift" } ] } [/block] Now, lets generate a Smart Link and send it in a text message! This will try to present a `MFMessageComposeViewController` on the `rootViewController` of your app. You may need to change this to the correct location for it to present from. [block:code] { "codes": [ { "code": "#import <MessageUI/MessageUI.h>\n\nNSDictionary *parameters = @{@\"res\": @\"Tim's Steakhouse\", @\"dinner_date\": @\"October 25th\"};\n\n[Primer getLinkForTargeting:@\"SHARES\" withParameters:parameters completion:^(NSString * _Nullable link) {\n // Check if the link is not nil.\n if (!link) {\n return\n }\n \n // Check if the device supports text messages.\n if (![MFMessageComposeViewController canSendText]) {\n return\n }\n \n // Create a new compose view controller.\n MFMessageComposeViewController *composeVC = [[MFMessageComposeViewController alloc] init];\n \n // Insert the link into the message.\n NSString *messageBody = [NSString stringWithFormat:@\"I made us dinner reservations on %@! RSVP here %@\", parameters[\"dinner_date\"], link];\n composeVC.body = messageBody;\n \n // Set the recipient.\n composeVC.recipients = @[@\"5164679651\"];\n \n // Prompt the user to send the message.\n AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;\n UIViewController *rootVC = appDelegate.window.rootViewController;\n [rootVC presentViewController:composeVC animated:YES completion:nil];\n}];", "language": "objectivec" }, { "code": "import MessageUI\n\nlet parameters = [\"res\": \"Tim's Steakhouse\", \"dinner_date\": \"October 25th\"]\n\nPrimer.getLinkForTargeting(\"SHARES\", withParameters: parameters) { (link: String?) in\n \n // Check if the link is not nil.\n guard (link != nil) else {\n \treturn\n }\n \n // Check if the device supports text messages.\n guard MFMessageComposeViewController.canSendText() else {\n \treturn\n }\n \n // Create a new compose view controller.\n let composeVC = MFMessageComposeViewController()\n \n // Insert the link into the message.\n let messageBody = String(format:\"I made us dinner reservations on %@! RSVP here %@\", parameters[\"dinner_date\"], link!)\n composeVC.body = messageBody\n \n // Set the recipient.\n composeVC.recipients = [\"5164679651\"]\n \n // Prompt the user to send the message.\n let appDelegate = UIApplication.shared.delegate as! AppDelegate\n let rootVC = appDelegate.window!.rootViewController!\n rootVC.present(composeVC, animated: true, completion: nil)\n}", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "You're Done!" } [/block] When your recipient clicks the link to install the app, they'll see a flow customized just for them! [block:image] { "images": [ { "image": [ "https://files.readme.io/KoBSbwh0R92QoRBDDmmI_invite_final.png", "invite_final.png", "1470", "734", "#a08956", "" ] } ] } [/block] Check out [Attribution](doc:attribution) for more information regarding Smart Links!