Edit: form update notifications are now provided by Collect through polling. See Notifications about form updates. A broader system for messaging push notifications may still be desired.
Ona has been hired by a client to add support for push notifications into ODK Collect. We already have a list of requirements from the client that need to be implemented before a deadline. Since our intention is to make this feature available to everyone else, we'd appreciate feedback from the community.
- Whenever a form schema, or any of its media files is updated on ODK Aggregate, a notification of the change should be sent to all devices with ODK Collect that have previous versions of the form. The notification message should be shown on the devices' notification centres.
- There should be an "Auto-download form changes" toggle in ODK Collect's settings:
- When the toggle is enabled, form schemas and media files will be auto-downloaded whenever a form update notification is received, and it's safe to update the form (the form is currently not opened).
- When the toggle is disabled, the form schema and media files are not auto-download whenever a form update notification is received. However, a "New form version available" alert message is displayed whenever a user opens the form from the "Fill Blank Form" screen. The alert message should be dismissable.
- An aggregate user should be able to send a free-form message to all devices that have a form downloaded in ODK Collect. The notification message should be shown on the device's notification centre, and should open up an activity with all received free-form messages arranged chronologically.
We will initially add support for pushing notifications from Ona Data, rather than ODK Aggregate.
In order to deliver this feature to our client in good time, we've considered three approaches of adding the features to Collect. This is potentially temporary, as we wait for the community to give the necessary feedback:
- Build a separate Android app that handles push notifications, and that 'talks' to Collect using broadcast messages. Depending on what the community decides, we will continue to maintain this as a separate app, or move all functionality to Collect.
- Create a feature branch in ODK Collect's repo on GitHub. Continue working from there as the community fully specs out the feature for use by everyone else.
- Implement the feature in our fork of ODK Collect. Push the code to ODK Collect when the community fully specs out the feature for use by everyone else.
Firebase/GCM, Amazon SNS, and Message Queue Telemetry Transport (MQTT) have been considered as possible technologies/protocols for the push notification system. We propose to use MQTT. Key points on the protocol:
- MQTT is an open protocol (vendor lock-in not possible).
- MQTT is payload agnostic allowing clients to send JSON payloads, for instance. In comparison, similar messaging protocols like XMPP would require wrapping the JSON inside XML.
- There are various client (including Android, Java, and Python), and broker implementations available.
- MQTT client libraries are not considered "first-class citizens" on Android. For instance, MQTT client libraries are unable to wake the device from sleep. In comparison, Firebase is able to wake the device from sleep if a high-priority message is received.
Though not finalized, there's an issue on GitHub suggesting the structure of push notification payloads.
Key points from a discussion we had on this feature request during the ODK Transition Planning workshop in Seattle:
- Push notification payloads for form updates contain the form manifest, and not the update diff.
- Should the "auto-download form update" toggle be a server level setting?
- It'd be great to add a "release notes" field in the form manifest pushed when a form update is published.
Implementation is set to begin in the second week of July 2017, and should take around five weeks to implement (based on the agreed upon timeline with the client).
Some areas we are looking out for feedback from the community are:
- What other requirements should we consider (but not necessarily implement immediately).
- What technology to use for push notifications.
- Help in beefing up the push notification spec for form updates, and free form messages.
- Suggestions on what the community thinks is the best way of adding the feature to ODK Collect.