{"__v":0,"_id":"57b96d6b1d08500e00bf81e4","category":{"__v":0,"_id":"57b96d6b1d08500e00bf81d3","project":"54861bb654b3ce0b00367292","version":"57b96d6b1d08500e00bf81d1","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"},"parentDoc":null,"project":"54861bb654b3ce0b00367292","user":"54861b9f3681d914006992a4","version":{"__v":7,"_id":"57b96d6b1d08500e00bf81d1","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":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"","version_clean":"4.0.0","version":"4.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":10,"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]