Notification Audience (WHO)¶
An important part of any push template is the audience which we be receiving notifications created from the template. Audience definition consists of several filters:
- device operating system (Android, iOS or both).
- messaging channel devices are registered with.
- user segment expressed as a query against the
When Backendless receives a request to publish a push notification, the system applies the filters and creates a list of devices which will be receiving the notification. Once the list is composed, Backendless proceeds with delivering the notification to the devices. This process is highly optimized to ensure minimal processing times and the fastest delivery process.
Operating System Filter¶
This filter consists of check boxes for each supported operating system. At the present moment available options include: All, Android and iOS. As Backendless push notification system evolves, additional options will become available.
When a device registers with Backendless to receive push notifications, a channel is specified in the registration API. As a result, the Channel filter lets you include into the audience all devices registered with a Backendless messaging channel. The final list of devices is calculated dynamically when Backendless receives a request to publish a push notification. Since the channel selection UI is implemented with a drop-down list, only one channel can be selected. However, if you need to create an audience for multiple channels, it can be accomplished using the Segment Filter (see below).
This filter is created with a "where clause" query applied against the
DeviceRegistration table. For example, the query shown below targets all devices registered with the
A query can reference any column in the
DeviceRegistration table, which has the following schema:
For example, the following query selects devices running Android 8.0:
operatingSystemName = 'ANDROID' and operationSystemVersion = '8.0'
A device registration may have a related user object in the
Users table. The relationship is established when a device registers from an application where there is a logged in Backendless user. The relationship between the
DeviceRegistration and the
Users tables is maintained through the
ownerId column define in the
DeviceRegistration table. Because of that, it is possible to create a selector which identifies the devices based on user criteria. For example, suppose you need to create a selector which identifies all devices for the users who have a @gmail.com email address and live in Chicago. consider the schemas below. Notice the
Users table schema below has the
address column, which is a relation to the
Address table. The address table schema has the
The Users table schema:
The Address table schema:
With the database schema defined as shown above, a query which selects devices for the users with a
@gmail.com email address who live in
ownerId IN (Users[email like '%@gmail.com' and address.city = 'Chicago'].objectId)
The structure of the query is based on the "searching with subquery" feature. A query inside of the square brackets of the
Users block selects all the users matching the query's condition. Then
Users.objectId gets a collection of the
objectId values for all the selected users. Finally, the
ownerId IN () part of the query selects all the devices from the
DeviceRegistration table which have
ownerId value in the collection of user's object IDs.
For all options defining the audience, Backendless Console calculates its size and displays it in the section above the phone image. The audience is recalculated when any of the parameters on the "WHO will get it" change, this includes operating system, channel or selector: