{"_id":"588861fa165af631008ee1d9","parentDoc":null,"user":"54861b9f3681d914006992a4","__v":0,"category":{"_id":"588861fa165af631008ee1ba","__v":0,"version":"588861fa165af631008ee1b8","project":"54861bb654b3ce0b00367292","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"},"project":"54861bb654b3ce0b00367292","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"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-02T17:33:17.185Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":15,"body":"##Get notified when all is in sync\nAfter the session has started and when it is restarted, you can be notified and continue with the app flow.\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Initial sync\",\n  \"body\": \"Interacting with cases and dynamic objects happen only after initial sync, so take into flow consideration.\"\n}\n[/block]\nYou can use the following two notifications keys for indication. \nWhile:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"ELASTICODE_SESSION_STARTED - for when session started the first time\\nELASTICODE_SESSION_RESTARTED - for when session restarted\",\n      \"language\": \"objectivec\",\n      \"name\": \"Objective-C/Swift\"\n    }\n  ]\n}\n[/block]\n\nFor example:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Register (listen) to local notification when session started\\n\\t[[NSNotificationCenter defaultCenter] addObserver: self\\n                                             selector: :::at:::selector(sessionStartedNotification:)\\n                                                 name: ELASTICODE_SESSION_STARTED\\n                                               object: nil];\",\n      \"language\": \"objectivec\",\n      \"name\": \"Objective-C\"\n    },\n    {\n      \"code\": \"// Register (listen) to local notification  when session started\\n  NSNotificationCenter\\n\\t\\t\\t.defaultCenter()\\n\\t\\t\\t.addObserver(\\n\\t\\t\\t\\tself, \\n\\t\\t\\t\\tselector: \\\"sessionStartedNotification:\\\", \\n\\t\\t\\t\\tname:ELASTICODE_SESSION_STARTED, \\n\\t\\t\\t\\tobject: nil)\",\n      \"language\": \"objectivec\",\n      \"name\": \"Swift\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"handlers-notifications","type":"basic","title":"Handlers & Notifications"}

Handlers & Notifications


##Get notified when all is in sync After the session has started and when it is restarted, you can be notified and continue with the app flow. [block:callout] { "type": "warning", "title": "Initial sync", "body": "Interacting with cases and dynamic objects happen only after initial sync, so take into flow consideration." } [/block] You can use the following two notifications keys for indication. While: [block:code] { "codes": [ { "code": "ELASTICODE_SESSION_STARTED - for when session started the first time\nELASTICODE_SESSION_RESTARTED - for when session restarted", "language": "objectivec", "name": "Objective-C/Swift" } ] } [/block] For example: [block:code] { "codes": [ { "code": "// Register (listen) to local notification when session started\n\t[[NSNotificationCenter defaultCenter] addObserver: self\n selector: @selector(sessionStartedNotification:)\n name: ELASTICODE_SESSION_STARTED\n object: nil];", "language": "objectivec", "name": "Objective-C" }, { "code": "// Register (listen) to local notification when session started\n NSNotificationCenter\n\t\t\t.defaultCenter()\n\t\t\t.addObserver(\n\t\t\t\tself, \n\t\t\t\tselector: \"sessionStartedNotification:\", \n\t\t\t\tname:ELASTICODE_SESSION_STARTED, \n\t\t\t\tobject: nil)", "language": "objectivec", "name": "Swift" } ] } [/block]