{"_id":"565f2b5d413e06170093de9e","category":{"_id":"562014108a05d7230006ffad","project":"54861bb654b3ce0b00367292","version":"5620140f8a05d7230006ffac","__v":18,"pages":["562014118a05d7230006ffb6","562014118a05d7230006ffb7","562014118a05d7230006ffb8","562014118a05d7230006ffb9","562014118a05d7230006ffba","562014118a05d7230006ffbb","562014118a05d7230006ffbc","562014118a05d7230006ffbd","562014118a05d7230006ffbe","562014118a05d7230006ffbf","562014118a05d7230006ffc0","5620146f8a05d72300070013","565ed96ff76b8d0d0055422b","565f1bb623fd5f0d00a12a51","565f2996413e06170093de98","565f29db0dc99e1900f24ba8","565f2b23649b951900c89724","565f2b5d413e06170093de9e","5666d8b46819320d000c2e10","5666dd1866debc1700503e38","5666e3da5d00370d00ede577","5666ef36f672550d000851aa","5666f1116819320d000c2e3e","5666f7bf6819320d000c2e53","5672d7fe3cab740d00d15a48","56e961cef3c3031900041af4","56ebc03943304e2900e2116f","56f116a0ab5e790e00fb3950"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-12-08T21:55:25.679Z","from_sync":false,"order":0,"slug":"1-setup","title":"Onboarding/Moment integration"},"version":{"_id":"5620140f8a05d7230006ffac","project":"54861bb654b3ce0b00367292","__v":3,"createdAt":"2015-10-15T21:01:03.908Z","releaseDate":"2015-10-15T21:01:03.908Z","categories":["562014108a05d7230006ffad","562014108a05d7230006ffae","562014108a05d7230006ffaf","562014108a05d7230006ffb0","562014108a05d7230006ffb1","562014108a05d7230006ffb2","562014108a05d7230006ffb3","562014108a05d7230006ffb4","562014108a05d7230006ffb5","5666f7f5d784a70d00397bff","56967935b6d61f0d00acfb0b"],"is_deprecated":true,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"Moments","version_clean":"2.0.0","version":"2.0"},"parentDoc":null,"user":"54861b9f3681d914006992a4","__v":12,"project":"54861bb654b3ce0b00367292","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":11,"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\": \"Defining and 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:\nELASTICODE_SESSION_STARTED - for when session started the first time\nELASTICODE_SESSION_RESTARTED - for when session restarted\nELASTICODE_MOMENT_DEFINED - for when moment is ready for display\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": "Defining and 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: ELASTICODE_SESSION_STARTED - for when session started the first time ELASTICODE_SESSION_RESTARTED - for when session restarted ELASTICODE_MOMENT_DEFINED - for when moment is ready for display 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]