{"_id":"599e32a963c312001947e588","category":"599e32a963c312001947e584","parentDoc":null,"user":"545a811ebf1d2b0e00aaa1f2","project":"57c88b374434350e00509d7f","version":"599e32a963c312001947e583","updates":["56f57ba8ab3f610e000a6597"],"next":{"pages":[],"description":""},"createdAt":"2015-09-15T23:40:34.851Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Follow these easy few steps to get Primer up and running in your iOS app in less than 10 minutes.\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. Install the SDK\"\n}\n[/block]\n####Using CocoaPods\nThe easiest and recommended way to install our SDK is via <a href=\"http://cocoapods.org/\" target=\"_blank\">CocoaPods</a>.\nJust add `pod 'Primer', '~> 3.5'` to your `Podfile`, then run `pod install`.\n\n####Using Carthage\nAlternatively, if you prefer to use <a href=\"https://github.com/Carthage/Carthage\" target=\"_blank\">Carthage</a>, just add `github \"goprimer/primer-ios-sdk\" ~> 3.5` to your `Cartfile`. Don't forget to add `$(SRCROOT)/Carthage/Build/iOS/Primer.framework` under \"Input Files\" for the `copy-frameworks` script Build Phase. Then add `AdSupport.framework` in the `Linked Frameworks and Libraries` section of the `General` tab of your app target's settings.\n\n####Manual Integration\nIf you prefer to take the scenic route, download the latest release of the SDK from our [GitHub repository](https://github.com/goprimer/primer-ios-sdk). Drag `Primer.framework` to the `Embedded Binaries` section of the `General` tab of your app target's settings in Xcode. Ensure `Copy items if needed` is selected. Then add `AdSupport.framework` in the `Linked Frameworks and Libraries` section. Finally, go to the `Build Phases` tab of the same target, and add a new `Run Script Phase`.\nExpand it, then paste the following into the code input field:\n`sh \"${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Primer.framework/integrate.sh\"`\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"2. Initialize the SDK\"\n}\n[/block]\n####Start The SDK\nFirst import Primer by adding `#import <Primer/Primer.h>` ( or `import Primer` for Swift) at the top of your application's delegate. Then in your `-application:didFinishLaunchingWithOptions:` implementation call our start method with your SDK token (you can find it in your <a href=\"http://goprimer.com/dashboard#/project//edit\" target=\"_blank\">Project Settings</a>).\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <Primer/Primer.h>\\n\\n- (BOOL)application:(UIApplication *)application\\ndidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\\n    // Initialize the Primer SDK\\n\\t  [Primer startWithToken::::at:::\\\"[[app:token]]\\\"];\\n    return YES;\\n}\\n\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"import Primer\\n\\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\\n    // Initialize the Primer SDK\\n    Primer.start(withToken: \\\"[[app:token]]\\\")\\n    return true\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"Alternatively, you now have the option to provide your token in your app's info plist, under the `PrimerToken` key, and simply call `+start` on Primer in `-application:didFinishLaunchingWithOptions:`.\"\n}\n[/block]\nIf your app doesn't require users to have an account, and you only want to show a screen the first time the app is installed and launched, call `+setRequiresLogin:` with `NO` (or `false` for Swift) on Primer before calling the start method.\n\n####Present Onboarding\nThe most common time to present an onboarding experience is right when the application launches. The best way of doing this in most of the applications is by calling the presentation method in the `-viewDidLoad` of your first view controller to be presented to the user on app load.\n\nTo let the SDK automatically present an onboarding experience just simply call the `+presentExperience` method.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"#import <Primer/Primer.h>\\n  \\n- (void)viewDidLoad {\\n    [super viewDidLoad];\\n\\t\\t// Present the Primer onboarding experience\\n    [Primer presentExperience];\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"import Primer\\n\\noverride func viewDidLoad() {\\n    super.viewDidLoad()\\n\\t\\t// Present the Primer onboarding experience\\n    Primer.presentExperience()\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"3. Track Goal Event\"\n}\n[/block]\nDepending on the type of your app, you will need to add either a `Purchased` or a `Subscribed` event. The goal event is highly recommended in order to track the performance of onboarding screens and flows.\n\nBoth of these events should have at least two parameters: `revenue` as a decimal number, and `currency` as an ISO 4217 standard string. The latter you can easily get from a number formatter’s `currencyCode` property.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"NSString *name = @\\\"Purchased\\\";\\nNSDictionary *parameters = @{ @\\\"revenue\\\": @(1.99), @\\\"currency\\\": @\\\"USD\\\", ... };\\n[Primer trackEventWithName:name parameters:parameters];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"let name = \\\"Purchased\\\"\\nlet parameters: [String : Any] = [ \\\"revenue\\\": 1.99, \\\"currency\\\": \\\"USD\\\", ... ]\\nPrimer.trackEvent(withName: name, parameters: parameters)\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"4. Permissions\"\n}\n[/block]\nEnable push notification requests by calling Primer's `+applicationDidRegisterUserNotificationSettings` method from your app delegate's `-application:didRegisterUserNotificationSettings:`. In case your app doesn't support iOS 9 and below, you can skip this.\n\nWith a recent update to the iTunes Connect upload process for iOS 10, Apple is requiring that all permissions you may request have usage descriptions in your app's info plist. Since Primer enables requesting any permission, Apple requires you to include all of them.  \n\nThese plist keys are:\n- `NSLocationAlwaysUsageDescription` for location (always),\n- `NSLocationWhenInUseUsageDescription` for location (when in use),\n- `NSContactsUsageDescription` for contacts,\n- `NSMicrophoneUsageDescription` for microphone,\n- `NSCameraUsageDescription` for camera,\n- and `NSPhotoLibraryUsageDescription` for photo library.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"5. Whitelist Domain\"\n}\n[/block]\niOS 9 introduced <a href=\"https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/plist/info/NSAppTransportSecurity\" target=\"_blank\">App Transport Security</a> that impacts your app and the Primer iOS SDK integration. You need to whitelist the Primer domain in your app by adding the following to your application's info plist.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<key>NSAppTransportSecurity</key>\\n<dict>\\n    <key>NSExceptionDomains</key>\\n    <dict>\\n        <key>goprimer.com</key>\\n        <dict>\\n            <key>NSIncludesSubdomains</key>\\n            <true/>\\n            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>\\n            <true/>\\n        </dict>\\n    </dict>\\n</dict>\",\n      \"language\": \"xml\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"\",\n  \"body\": \"Pro tip! If you right-click the info plist file in the project navigator and select `Open As` > `Source Code`, you can easily copy and paste the XML snippet under the main `<dict>` tag.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Flows Launched!\"\n}\n[/block]\nBuild and run your application to see the automatic Primer onboarding experience!\nYou can design and edit your flows easily on the <a href=\"http://goprimer.com/dashboard\" target=\"_blank\">Dashboard</a>.\nUse Deep Link URIs (i.e. yourapp://coupon) to easily navigate to specific screens in your app.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Not seeing anything appear?\",\n  \"body\": \"Go to the <a href=\\\"http://goprimer.com/dashboard\\\" target=\\\"_blank\\\">Dashboard</a> and ensure that your organic flow is currently running. If it isn't, no flow will appear on initialization.\\n\\nAdditionally, if your app uses complicated view hierarchies, please read more about the advanced presentation techniques described in [Onboarding](doc:onboarding).\"\n}\n[/block]\nCongratulations on launching flows! Continue on to the authentication guide to activate all of Primer's functionality.\n\n####Authentication\nContinue on with the **[Quick Authentication Guide](doc:quick-authentication-guide).**","excerpt":"","slug":"quick-start","type":"basic","title":"Quick Start Guide","__v":0,"childrenPages":[]}
Follow these easy few steps to get Primer up and running in your iOS app in less than 10 minutes. Need help or have questions? Don't hesitate to [Contact Us](doc:contact-us)! [block:api-header] { "type": "basic", "title": "1. Install the SDK" } [/block] ####Using CocoaPods The easiest and recommended way to install our SDK is via <a href="http://cocoapods.org/" target="_blank">CocoaPods</a>. Just add `pod 'Primer', '~> 3.5'` to your `Podfile`, then run `pod install`. ####Using Carthage Alternatively, if you prefer to use <a href="https://github.com/Carthage/Carthage" target="_blank">Carthage</a>, just add `github "goprimer/primer-ios-sdk" ~> 3.5` to your `Cartfile`. Don't forget to add `$(SRCROOT)/Carthage/Build/iOS/Primer.framework` under "Input Files" for the `copy-frameworks` script Build Phase. Then add `AdSupport.framework` in the `Linked Frameworks and Libraries` section of the `General` tab of your app target's settings. ####Manual Integration If you prefer to take the scenic route, download the latest release of the SDK from our [GitHub repository](https://github.com/goprimer/primer-ios-sdk). Drag `Primer.framework` to the `Embedded Binaries` section of the `General` tab of your app target's settings in Xcode. Ensure `Copy items if needed` is selected. Then add `AdSupport.framework` in the `Linked Frameworks and Libraries` section. Finally, go to the `Build Phases` tab of the same target, and add a new `Run Script Phase`. Expand it, then paste the following into the code input field: `sh "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/Primer.framework/integrate.sh"` [block:api-header] { "type": "basic", "title": "2. Initialize the SDK" } [/block] ####Start The SDK First import Primer by adding `#import <Primer/Primer.h>` ( or `import Primer` for Swift) at the top of your application's delegate. Then in your `-application:didFinishLaunchingWithOptions:` implementation call our start method with your SDK token (you can find it in your <a href="http://goprimer.com/dashboard#/project//edit" target="_blank">Project Settings</a>). [block:code] { "codes": [ { "code": "#import <Primer/Primer.h>\n\n- (BOOL)application:(UIApplication *)application\ndidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {\n // Initialize the Primer SDK\n\t [Primer startWithToken:@\"[[app:token]]\"];\n return YES;\n}\n", "language": "objectivec" }, { "code": "import Primer\n\nfunc application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {\n // Initialize the Primer SDK\n Primer.start(withToken: \"[[app:token]]\")\n return true\n}", "language": "swift" } ] } [/block] [block:callout] { "type": "info", "body": "Alternatively, you now have the option to provide your token in your app's info plist, under the `PrimerToken` key, and simply call `+start` on Primer in `-application:didFinishLaunchingWithOptions:`." } [/block] If your app doesn't require users to have an account, and you only want to show a screen the first time the app is installed and launched, call `+setRequiresLogin:` with `NO` (or `false` for Swift) on Primer before calling the start method. ####Present Onboarding The most common time to present an onboarding experience is right when the application launches. The best way of doing this in most of the applications is by calling the presentation method in the `-viewDidLoad` of your first view controller to be presented to the user on app load. To let the SDK automatically present an onboarding experience just simply call the `+presentExperience` method. [block:code] { "codes": [ { "code": "#import <Primer/Primer.h>\n \n- (void)viewDidLoad {\n [super viewDidLoad];\n\t\t// Present the Primer onboarding experience\n [Primer presentExperience];\n}", "language": "objectivec" }, { "code": "import Primer\n\noverride func viewDidLoad() {\n super.viewDidLoad()\n\t\t// Present the Primer onboarding experience\n Primer.presentExperience()\n}", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "3. Track Goal Event" } [/block] Depending on the type of your app, you will need to add either a `Purchased` or a `Subscribed` event. The goal event is highly recommended in order to track the performance of onboarding screens and flows. Both of these events should have at least two parameters: `revenue` as a decimal number, and `currency` as an ISO 4217 standard string. The latter you can easily get from a number formatter’s `currencyCode` property. [block:code] { "codes": [ { "code": "NSString *name = @\"Purchased\";\nNSDictionary *parameters = @{ @\"revenue\": @(1.99), @\"currency\": @\"USD\", ... };\n[Primer trackEventWithName:name parameters:parameters];", "language": "objectivec" }, { "code": "let name = \"Purchased\"\nlet parameters: [String : Any] = [ \"revenue\": 1.99, \"currency\": \"USD\", ... ]\nPrimer.trackEvent(withName: name, parameters: parameters)", "language": "swift" } ] } [/block] [block:api-header] { "type": "basic", "title": "4. Permissions" } [/block] Enable push notification requests by calling Primer's `+applicationDidRegisterUserNotificationSettings` method from your app delegate's `-application:didRegisterUserNotificationSettings:`. In case your app doesn't support iOS 9 and below, you can skip this. With a recent update to the iTunes Connect upload process for iOS 10, Apple is requiring that all permissions you may request have usage descriptions in your app's info plist. Since Primer enables requesting any permission, Apple requires you to include all of them. These plist keys are: - `NSLocationAlwaysUsageDescription` for location (always), - `NSLocationWhenInUseUsageDescription` for location (when in use), - `NSContactsUsageDescription` for contacts, - `NSMicrophoneUsageDescription` for microphone, - `NSCameraUsageDescription` for camera, - and `NSPhotoLibraryUsageDescription` for photo library. [block:api-header] { "type": "basic", "title": "5. Whitelist Domain" } [/block] iOS 9 introduced <a href="https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/plist/info/NSAppTransportSecurity" target="_blank">App Transport Security</a> that impacts your app and the Primer iOS SDK integration. You need to whitelist the Primer domain in your app by adding the following to your application's info plist. [block:code] { "codes": [ { "code": "<key>NSAppTransportSecurity</key>\n<dict>\n <key>NSExceptionDomains</key>\n <dict>\n <key>goprimer.com</key>\n <dict>\n <key>NSIncludesSubdomains</key>\n <true/>\n <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>\n <true/>\n </dict>\n </dict>\n</dict>", "language": "xml" } ] } [/block] [block:callout] { "type": "info", "title": "", "body": "Pro tip! If you right-click the info plist file in the project navigator and select `Open As` > `Source Code`, you can easily copy and paste the XML snippet under the main `<dict>` tag." } [/block] [block:api-header] { "type": "basic", "title": "Flows Launched!" } [/block] Build and run your application to see the automatic Primer onboarding experience! You can design and edit your flows easily on the <a href="http://goprimer.com/dashboard" target="_blank">Dashboard</a>. Use Deep Link URIs (i.e. yourapp://coupon) to easily navigate to specific screens in your app. [block:callout] { "type": "warning", "title": "Not seeing anything appear?", "body": "Go to the <a href=\"http://goprimer.com/dashboard\" target=\"_blank\">Dashboard</a> and ensure that your organic flow is currently running. If it isn't, no flow will appear on initialization.\n\nAdditionally, if your app uses complicated view hierarchies, please read more about the advanced presentation techniques described in [Onboarding](doc:onboarding)." } [/block] Congratulations on launching flows! Continue on to the authentication guide to activate all of Primer's functionality. ####Authentication Continue on with the **[Quick Authentication Guide](doc:quick-authentication-guide).**