Push Notifications for Android and Apple Devices

Push notifications allow you to send messages and alerts to Android and Apple devices from external apps or processes which are separate from your Digitise apps. These notifications work in a similar way to notifications for other mobile apps, such as from games, messaging and social media apps, which most users will already be very familiar with. Each push notification is targeted at a specific Digitise app and can include data to be passed to the app within it. Notifications can be received whether the target app is running or not.

For example, suppose you have a Digitise app which provides a list of jobs for the user to work through and update on their mobile device and that this job list is stored in a central database and downloaded to the device at the start of each day. You could then have an app or process, separate from your Digitise Apps environment, which would notify users if the database is updated and the job list changes during the day, by sending a push notification to interested users. This app or process could be the same app or process which updates the database or it could be a separate app or process. The notification could contain the new data or initiate an automatic download of the updated database if required or the app can provide a mechanism for the user to update the data manually.

 

Push notifications are supported in both apps which are run from within a standard Digitise Apps Client and those deployed as Standalone Apps, but are only supported for the Android and Apple Platforms.

 

On the device, when a push notification is received, it will, generally, appear in the device's notification area in the standard manner for the device, although on iOS devices if the app is already running in the foreground, the app will display the notification rather than the notification centre. The user can tap or click on the notification to acknowledge the notification, which will bring the target app into the foreground - if necessary the app or Digitise Apps Client/target app will be loaded first, if not already running.

Once the target app is in the foreground, the OnSystemNotification Event will be triggered, just as with system notifications, and, if a Script has been assigned to the Event, that Script will run, allowing you to automatically perform a set of actions without user intervention, for example to automatically redownload an updated Data Source or handle any data included within the notification. The push notification must include a 'tag' value which will be passed to the OnSystemNotification Event to identify the notification's source (see below for more information) allowing you to use the OnSystemNotification Event for notifications from different sources. There is only one OnSystemNotification Event which is shared between all notifications - both push and system. This means that you can only assign one Script to the Event, which therefore has to cover the required actions for all notifications the app might receive. The supplied tag value is automatically stored in a predefined variable, Tag, and is used to identify the notification. The Tag variable can be accessed throughout your Script, and thus can be used to isolate those parts of the Script which relate to individual notifications.

The OnSystemNotification Event is an application-level Event, which can be accessed in App Studio from the Project Properties.

  • If the app named in the notification is a secondary app, i.e. it is launched from within another app, when the notification is acknowledged the secondary app will only be brought to the foreground if it is already running. If it is not running, the main primary app will be loaded or brought to the foreground instead and the OnSystemNotification Event in this app will be triggered.

 

 

If you include support for push notifications, every time you load the Standalone App or Digitise Apps Client it will automatically attempt to contact the relevant push notification service and register itself with the service. The service returns a unique identifier, called a push token, which identifies the device and Digitise Apps Client combination. When the app or process responsible for initiating push notifications requests a push notification, it will need to provide the relevant push token value in the request. This tells the push notification service which device and Digitise Apps Client it should send the notification to.

Consequently, a user should have a connection available the first time they load a new Digitise app or Client, otherwise they won't be able to register with the push notification service and won't receive push notifications. In this situation, you could tell your users to close and reload the app or Client when they have a signal again, or you could provide a Script within your app which will attempt to register with the notification service, using the RegisterForPush Scripting Method, and then, for example, assign that Script to a Button allowing the user to manually register or to a Timer for automatic retries, disabling the Timer once the device has registered.

Once the Client has registered with the notification service, it will still re-register whenever the app or Client is loaded. In general, the push token returned should remain the same each time a particular client registers, but this is not guaranteed. This means that if a device has no signal when the Client or app loads, it should still be able to receive push notifications using the same push token as before once it has a signal, even though it has been unable to reach the notification service on loading.

The push token identifies a Digitise Apps Client running on a specific device, rather than a Digitise app. Consequently, when requesting a notification, you include the name of the app the notification is intended for within the request, so that the Digitise Apps Client can deal with the notification correctly. (Remember a Standalone App includes a version of the Digitise Apps Client bundled within the app. The push token identifies the device and Digitise Apps Client and the notification payload then includes the name of the app.)

  • You must make sure that devices are not prevented from contacting the relevant push notification service due to firewall restrictions.

 

Since it isn't Digitise Apps which will send out the push notifications themselves, your Standalone Apps or Digitise Apps Clients need to be able to share their push tokens with the apps or processes which will actually send out the notifications, so that they can send notifications to the appropriate devices. One solution is to create a database to store the values in and upload the push token values from your Digitise apps to this database. The database will need to be accessible to the apps or processes which send out the notifications. The GetPushToken Scripting Method allows you to obtain the push token value within a Script and could be called from the Project's OnLoad Event.


See also:

GetPushNotificationPayload

GetPushToken

RegisterForPush