{"_id":"588861fc165af631008ee216","__v":0,"category":{"_id":"588861fa165af631008ee1c0","project":"54861bb654b3ce0b00367292","__v":0,"version":"588861fa165af631008ee1b8","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-09-19T08:12:32.921Z","from_sync":false,"order":7,"slug":"cordova-app-triggers","title":"Cordova / App triggers"},"project":"54861bb654b3ce0b00367292","user":"548d74b716fc980b00e2a786","version":{"_id":"588861fa165af631008ee1b8","__v":1,"project":"54861bb654b3ce0b00367292","createdAt":"2017-01-25T08:29:46.061Z","releaseDate":"2017-01-25T08:29:46.061Z","categories":["588861fa165af631008ee1b9","588861fa165af631008ee1ba","588861fa165af631008ee1bb","588861fa165af631008ee1bc","588861fa165af631008ee1bd","588861fa165af631008ee1be","588861fa165af631008ee1bf","588861fa165af631008ee1c0","588861fa165af631008ee1c1","588861fa165af631008ee1c2","588861fa165af631008ee1c3","588861fa165af631008ee1c4","588861fa165af631008ee1c5","588861fa165af631008ee1c6","588861fa165af631008ee1c7","588861fa165af631008ee1c8","588861fa165af631008ee1c9"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"5.0.0","version":"5.0"},"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-19T08:12:05.804Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":48,"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\"  (iOS only)\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:setup-1) integration ):\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var params = window.elasticode.createSessionParamsObject();\\nvar inProduction = false;\\nwindow.elasticode.setSessionParams(inProduction, params);\",\n      \"language\": \"javascript\"\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\": \"onDeviceReady: function() {\\n\\tapp.receivedEvent('deviceready');\\n  \\n  window.elasticode.setAndroidApiKey(\\\"<AndroidAPIKey>\\\");\\n  window.elasticode.setIOSApiKey(\\\"<iOSAPIKey>\\\");\\n  \\n  // Basic app triggers setup \\n  var params = window.elasticode.createSessionParamsObject();\\n  var inProduction = false;\\n\\twindow.elasticode.setSessionParams(inProduction, params);\\n  \\n\\twindow.elasticode.ready();\\n}\",\n      \"language\": \"javascript\"\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\": \"// under your app settings:\\nvar app = {\\n  //...\\n  bindEvents: function(){\\n    document.addEventListener('deviceready', this.onDeviceReady, false);\\n    document.addEventListener('EC_SessionStarted', ec_started, false);\\n    document.addEventListener('EC_SessionRestarted', ec_restarted, false);\\n    //...\\n    \\n  },\\n  //...\\n};\\nfunction ec_started(e) {\\n  // Session has started (onLaunch will appear if needed)\\n    console.log(e.detail);\\n}\\nfunction ec_restarted(e) {\\n  // Session has updated/restarted \\n  // e.detail has information about:\\n  // - sync finish successfully\\n  // - moments that going to show/not show\\n    console.log(e.detail);\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]","excerpt":"Cordova / App triggers / Basic setup","slug":"basic-setup-1","type":"basic","title":"Basic setup"}

Basic setup

Cordova / 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" (iOS only) [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:setup-1) integration ): [block:code] { "codes": [ { "code": "var params = window.elasticode.createSessionParamsObject();\nvar inProduction = false;\nwindow.elasticode.setSessionParams(inProduction, params);", "language": "javascript" } ] } [/block] So the full integration ( till this point ), i.e. Essentials Kit + Basic App triggers [block:code] { "codes": [ { "code": "onDeviceReady: function() {\n\tapp.receivedEvent('deviceready');\n \n window.elasticode.setAndroidApiKey(\"<AndroidAPIKey>\");\n window.elasticode.setIOSApiKey(\"<iOSAPIKey>\");\n \n // Basic app triggers setup \n var params = window.elasticode.createSessionParamsObject();\n var inProduction = false;\n\twindow.elasticode.setSessionParams(inProduction, params);\n \n\twindow.elasticode.ready();\n}", "language": "javascript" } ] } [/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": "// under your app settings:\nvar app = {\n //...\n bindEvents: function(){\n document.addEventListener('deviceready', this.onDeviceReady, false);\n document.addEventListener('EC_SessionStarted', ec_started, false);\n document.addEventListener('EC_SessionRestarted', ec_restarted, false);\n //...\n \n },\n //...\n};\nfunction ec_started(e) {\n // Session has started (onLaunch will appear if needed)\n console.log(e.detail);\n}\nfunction ec_restarted(e) {\n // Session has updated/restarted \n // e.detail has information about:\n // - sync finish successfully\n // - moments that going to show/not show\n console.log(e.detail);\n}", "language": "javascript" } ] } [/block]