{"__v":0,"_id":"588861fb165af631008ee208","category":{"version":"588861fa165af631008ee1b8","project":"54861bb654b3ce0b00367292","_id":"588861fa165af631008ee1bd","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-09-11T10:01:00.892Z","from_sync":false,"order":4,"slug":"android-app-triggers","title":"Android / App triggers"},"parentDoc":null,"project":"54861bb654b3ce0b00367292","user":"548d74b716fc980b00e2a786","version":{"__v":1,"_id":"588861fa165af631008ee1b8","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-11T10:01:55.964Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":37,"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[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"On launch\",\n  \"body\": \"Is an 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\": \"// bool parameter - in production?\\nElasticodeSessionParams params = new ElasticodeSessionParams(false, this); \\nelasticode.setSessionParams(params);\",\n      \"language\": \"java\"\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\": \":::at:::Override\\nprotected void onCreate(Bundle savedInstanceState) {\\n\\tsuper.onCreate(savedInstanceState);\\n  setContentView(R.layout.ac_main);\\n\\t\\n  // basic setup\\n  elasticode = Elasticode.getInstance(this, \\\"<APIKey>\\\", elasticodeObserver);\\n  \\n  // app triggers basic setup\\n  ElasticodeSessionParams params = \\n    new ElasticodeSessionParams(false, this);\\n\\telasticode.setSessionParams(params);\\n  \\n  elasticode.ready();\\n\\n}\",\n      \"language\": \"java\"\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 behavior there\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"private Observer elasticodeObserver = new Observer() {\\n\\t@Override\\n\\tpublic void update(Observable observable, Object data) {\\n\\t\\tif (data instanceof ElasticodeResponse) {\\n\\t\\t\\tElasticodeResponse response = (ElasticodeResponse) data;\\n\\t\\t\\tif (response.getError() != null) {\\n\\t\\t\\t\\t// In case of error\\n\\t\\t\\t} else {\\n\\t\\t\\t\\tswitch (response.getType()) {\\n\\t\\t\\t\\t\\tcase ON_LAUNCH_DISPLAYED:\\n            Boolean didApeared = ((Boolean) response.getAdditionalData());\\n\\t\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t\\t// put here all types (ElasticodeResponseType) which you want to handle\\n\\t\\t\\t\\t}\\n        }\\n\\t\\t}\\n\\t}\\n};\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"basic-setup","type":"basic","title":"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" [block:callout] { "type": "info", "title": "On launch", "body": "Is an 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": "// bool parameter - in production?\nElasticodeSessionParams params = new ElasticodeSessionParams(false, this); \nelasticode.setSessionParams(params);", "language": "java" } ] } [/block] So the full integration ( till this point ), i.e. Essentials Kit + Basic App triggers [block:code] { "codes": [ { "code": "@Override\nprotected void onCreate(Bundle savedInstanceState) {\n\tsuper.onCreate(savedInstanceState);\n setContentView(R.layout.ac_main);\n\t\n // basic setup\n elasticode = Elasticode.getInstance(this, \"<APIKey>\", elasticodeObserver);\n \n // app triggers basic setup\n ElasticodeSessionParams params = \n new ElasticodeSessionParams(false, this);\n\telasticode.setSessionParams(params);\n \n elasticode.ready();\n\n}", "language": "java" } ] } [/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 behavior there [block:code] { "codes": [ { "code": "private Observer elasticodeObserver = new Observer() {\n\t@Override\n\tpublic void update(Observable observable, Object data) {\n\t\tif (data instanceof ElasticodeResponse) {\n\t\t\tElasticodeResponse response = (ElasticodeResponse) data;\n\t\t\tif (response.getError() != null) {\n\t\t\t\t// In case of error\n\t\t\t} else {\n\t\t\t\tswitch (response.getType()) {\n\t\t\t\t\tcase ON_LAUNCH_DISPLAYED:\n Boolean didApeared = ((Boolean) response.getAdditionalData());\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t// put here all types (ElasticodeResponseType) which you want to handle\n\t\t\t\t}\n }\n\t\t}\n\t}\n};", "language": "java" } ] } [/block]