{"_id":"588861fb165af631008ee209","project":"54861bb654b3ce0b00367292","category":{"_id":"588861fa165af631008ee1bd","version":"588861fa165af631008ee1b8","project":"54861bb654b3ce0b00367292","__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"},"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"},"__v":0,"user":"548d74b716fc980b00e2a786","parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-11T11:11:38.060Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":38,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Add more locations along your app\"\n}\n[/block]\nNext step, let's add more places in your app where you can launch experiences.\n* When a screen loads\n* When you click on a button\n* etc...\nRead more about appTriggers here.\n\nEach app trigger needs to get a \"Define\" ( and you have a completion block as well, to run code once the sync per app trigger is completed) \n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Add the app trigger in the dashboard first\",\n  \"body\": \"Than add the following code in your client app\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"params.data.defineAppTrigger(\\\"triggerName\\\");\",\n      \"language\": \"java\",\n      \"name\": \"Java\"\n    }\n  ]\n}\n[/block]\nThis code should be inserted before initiating a session, here:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \":::at:::Override\\nprotected void onCreate(Bundle savedInstanceState) {\\n  super.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 \\n  // define app trigger \\n  params.data.defineAppTrigger(\\\"triggerName\\\");\\n  \\n  elasticode.setSessionParams(params);\\n  elasticode.ready();\\n\\n}\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"danger\",\n  \"title\": \"This is only a definition, it will not launch an experience  for this app trigger ( yet )\",\n  \"body\": \"To **launch** triggers, read here : [Running appTriggers](doc:running-apptriggers)\"\n}\n[/block]","excerpt":"","slug":"app-triggers-setup","type":"basic","title":"App triggers setup"}

App triggers setup


[block:api-header] { "type": "basic", "title": "Add more locations along your app" } [/block] Next step, let's add more places in your app where you can launch experiences. * When a screen loads * When you click on a button * etc... Read more about appTriggers here. Each app trigger needs to get a "Define" ( and you have a completion block as well, to run code once the sync per app trigger is completed) [block:callout] { "type": "info", "title": "Add the app trigger in the dashboard first", "body": "Than add the following code in your client app" } [/block] [block:code] { "codes": [ { "code": "params.data.defineAppTrigger(\"triggerName\");", "language": "java", "name": "Java" } ] } [/block] This code should be inserted before initiating a session, here: [block:code] { "codes": [ { "code": "@Override\nprotected void onCreate(Bundle savedInstanceState) {\n super.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 \n // define app trigger \n params.data.defineAppTrigger(\"triggerName\");\n \n elasticode.setSessionParams(params);\n elasticode.ready();\n\n}", "language": "java" } ] } [/block] [block:callout] { "type": "danger", "title": "This is only a definition, it will not launch an experience for this app trigger ( yet )", "body": "To **launch** triggers, read here : [Running appTriggers](doc:running-apptriggers)" } [/block]