Skip to content

Broadcast Events API

ctsims edited this page Sep 8, 2017 · 2 revisions

Broadcast Event API

For applications which are utilizing CommCare's internal API's, CommCare signals certain events through Broadcast Notifications on the device. Any application can receive these events regardless of their permissions status re:CommCare permissions, etc.

Prerequisites

In order to use this API, you'll need

  • An application installed in CommCare

Workflow

CommCare will broadcast certain Intents when events occur on the device that may be of note to external applications. For instance, an application could use the update event to refresh its (in memory) cache of API data.

Broadcasts

Action: org.commcare.dalvik.api.action.data.update

Fired when CommCare has finished a write to its database. Applications receiving this event may want to refresh any caches they are holding in memory of app data.

Action: org.commcare.dalvik.api.action.session.login

Fired when a user has logged into CommCare, and the content provider for that user's sandbox is available to applications with the appropriate permissions.

Action: org.commcare.dalvik.api.action.session.logout

Fired when a user session has ended. After this event the app content providers will no longer provide any data. Note - Since data is decrypted by the current user's session this is not the only way in which that session can end. If the app crashes or other wayward behavior occurs that causes the user's keys to be dropped from working memory, this event may not be fired if outside of the application's control.