{"_id":"57b96d6c1d08500e00bf8225","parentDoc":null,"__v":1,"user":"54861b9f3681d914006992a4","project":"54861bb654b3ce0b00367292","version":{"_id":"57b96d6b1d08500e00bf81d1","__v":7,"project":"54861bb654b3ce0b00367292","createdAt":"2016-08-21T08:59:23.326Z","releaseDate":"2016-08-21T08:59:23.326Z","categories":["57b96d6b1d08500e00bf81d2","57b96d6b1d08500e00bf81d3","57b96d6b1d08500e00bf81d4","57b96d6b1d08500e00bf81d5","57b96d6b1d08500e00bf81d6","57b96d6b1d08500e00bf81d7","57b96d6b1d08500e00bf81d8","57b96d6b1d08500e00bf81d9","57b96d6b1d08500e00bf81da","57b96d6b1d08500e00bf81db","57b96d6b1d08500e00bf81dc","57b97748306b9b0e001dd53f","57d12c6c1227b40e0044908a","57d51ad68191880e008bb51b","57d52b5cf350090e00fe073e","57d5468a17b492170053a3f0","57df9df05927cb0e002bce1e"],"is_deprecated":true,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"","version_clean":"4.0.0","version":"4.0"},"category":{"_id":"57b96d6b1d08500e00bf81d3","project":"54861bb654b3ce0b00367292","version":"57b96d6b1d08500e00bf81d1","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-12-08T21:55:25.679Z","from_sync":false,"order":1,"slug":"1-setup","title":"iOS / App Triggers"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-08T13:18:44.215Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic premium integration (Mandatory)\"\n}\n[/block]\n**Less than a minute** and you can personalize and segment multiple experiences in your app \n* \"On launch\"\n* \"Backview\" \n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"On launch / Backview\",\n  \"body\": \"These are two app triggers that are pre set by our system\"\n}\n[/block]\nYou would need to add these two rows ( In addition to the [Essentials kit](doc:sdk-intro)  integration ) :\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ECSessionParams* params = [ECSessionParams createInProduction:NO];\\n[ElastiCode setSessionParams:params];\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"let params:ECSessionParams = ECSessionParams .createInProduction(false)\\nElastiCode.setSessionParams(params)\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\nSo the full integration ( till this point ), i.e. Essentials Kit + Basic App triggers\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions\\n  (NSDictionary *)launchOptions {\\n  \\n        // basic setup\\t\\n  \\t\\t\\t[ElastiCode setAPIKey::::at:::\\\"<APIKey>\\\"]; \\n \\t\\t\\t   \\n        /// app triggers basic setup\\n        ECSessionParams* params = [ECSessionParams createInProduction:NO];\\n\\t\\t\\t  [ElastiCode setSessionParams:params];\\n  \\n        [ElastiCode ready];\\n  return YES;\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"class AppDelegate: UIResponder, UIApplicationDelegate {\\nvar window: UIWindow?\\n\\nfunc application(application: UIApplication, didFinishLaunchingWithOptions\\n       launchOptions: [NSObject: AnyObject]?) -> Bool {\\n    // Override point for customization after application launch.\\n   \\n    // basic setup   \\n    ElastiCode.setAPIKey(\\\"<APIKey>\\\")\\n    \\n    // app triggers basic setup\\n    let params:ECSessionParams = ECSessionParams .createInProduction(false)\\n\\t\\tElastiCode.setSessionParams(params)\\n    \\n    ElastiCode.ready()\\n    return true\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Sync completion (optional)\",\n  \"body\": \"\"\n}\n[/block]\nIn some cases you would like to know if the asynchronous function [ElastiCode ready]; has completed, and you might want to \"run\" your own propriety behaviour there\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Add observer before calling [ElastiCode ready]\\n[[NSNotificationCenter defaultCenter] addObserver:self \\n selector:@selector(_elasticodeSessionStarted:) name:ELASTICODE_SESSION_STARTED object:nil];\\n\\n-(void) _elasticodeSessionStarted:(NSNotification*) note\\n{\\n    NSDictionary* response = [note userInfo];\\n    if(response){\\n        NSNumber* success = [response objectForKey:@\\\"success\\\"];\\n        if([success boolValue]){\\n          // Elasticode session has started\\n          // Here you can add you custom logic\\n        }\\n    }\\n}\",\n      \"language\": \"objectivec\"\n    },\n    {\n      \"code\": \"// Add observer before calling ElastiCode.ready()\\nNSNotificationCenter.defaultCenter()\\n            .addObserver(self, selector: #selector(elasticodeSessionStartedNotification),\\n                         name: ELASTICODE_SESSION_STARTED, object: nil)\\n  \\nfunc elasticodeSessionStartedNotification(notif: NSNotification){\\n\\tif let userInfo:Dictionary<String,AnyObject> =\\n\\t\\tnotif.userInfo as? Dictionary<String,AnyObject>{\\n\\t\\t\\tlet success = userInfo[\\\"success\\\"] as! NSNumber;\\n\\t\\t\\tif(!success .boolValue){    \\n            }\\n        }\\n}\",\n      \"language\": \"swift\"\n    }\n  ]\n}\n[/block]","excerpt":"IOS / APP TRIGGERS: Basic setup","slug":"setup-flow-advanced","type":"basic","title":"Basic setup"}

Basic setup

IOS / APP TRIGGERS: Basic setup

[block:api-header] { "type": "basic", "title": "Basic premium integration (Mandatory)" } [/block] **Less than a minute** and you can personalize and segment multiple experiences in your app * "On launch" * "Backview" [block:callout] { "type": "info", "title": "On launch / Backview", "body": "These are two app triggers that are pre set by our system" } [/block] You would need to add these two rows ( In addition to the [Essentials kit](doc:sdk-intro) integration ) : [block:code] { "codes": [ { "code": "ECSessionParams* params = [ECSessionParams createInProduction:NO];\n[ElastiCode setSessionParams:params];", "language": "objectivec" }, { "code": "let params:ECSessionParams = ECSessionParams .createInProduction(false)\nElastiCode.setSessionParams(params)", "language": "swift" } ] } [/block] So the full integration ( till this point ), i.e. Essentials Kit + Basic App triggers [block:code] { "codes": [ { "code": "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions\n (NSDictionary *)launchOptions {\n \n // basic setup\t\n \t\t\t[ElastiCode setAPIKey:@\"<APIKey>\"]; \n \t\t\t \n /// app triggers basic setup\n ECSessionParams* params = [ECSessionParams createInProduction:NO];\n\t\t\t [ElastiCode setSessionParams:params];\n \n [ElastiCode ready];\n return YES;\n}", "language": "objectivec" }, { "code": "class AppDelegate: UIResponder, UIApplicationDelegate {\nvar window: UIWindow?\n\nfunc application(application: UIApplication, didFinishLaunchingWithOptions\n launchOptions: [NSObject: AnyObject]?) -> Bool {\n // Override point for customization after application launch.\n \n // basic setup \n ElastiCode.setAPIKey(\"<APIKey>\")\n \n // app triggers basic setup\n let params:ECSessionParams = ECSessionParams .createInProduction(false)\n\t\tElastiCode.setSessionParams(params)\n \n ElastiCode.ready()\n return true\n}", "language": "swift" } ] } [/block] [block:callout] { "type": "info", "title": "Sync completion (optional)", "body": "" } [/block] In some cases you would like to know if the asynchronous function [ElastiCode ready]; has completed, and you might want to "run" your own propriety behaviour there [block:code] { "codes": [ { "code": "// Add observer before calling [ElastiCode ready]\n[[NSNotificationCenter defaultCenter] addObserver:self \n selector:@selector(_elasticodeSessionStarted:) name:ELASTICODE_SESSION_STARTED object:nil];\n\n-(void) _elasticodeSessionStarted:(NSNotification*) note\n{\n NSDictionary* response = [note userInfo];\n if(response){\n NSNumber* success = [response objectForKey:@\"success\"];\n if([success boolValue]){\n // Elasticode session has started\n // Here you can add you custom logic\n }\n }\n}", "language": "objectivec" }, { "code": "// Add observer before calling ElastiCode.ready()\nNSNotificationCenter.defaultCenter()\n .addObserver(self, selector: #selector(elasticodeSessionStartedNotification),\n name: ELASTICODE_SESSION_STARTED, object: nil)\n \nfunc elasticodeSessionStartedNotification(notif: NSNotification){\n\tif let userInfo:Dictionary<String,AnyObject> =\n\t\tnotif.userInfo as? Dictionary<String,AnyObject>{\n\t\t\tlet success = userInfo[\"success\"] as! NSNumber;\n\t\t\tif(!success .boolValue){ \n }\n }\n}", "language": "swift" } ] } [/block]