Skip to content

Notification Content (WHAT)

This section contains the actual content delivered in a push notification generated from a template, this is why we refer to it as the "WHAT message says" section, or simply "WHAT". The content you can define includes:

  • Push notification message text
  • Notification title
  • Notification subtitle
  • Notification headers

As you edit the content, Backendless Console provides a preview of the notification for both Android and iOS devices:

composing-new-push-what-section

Smart Text

The message, title and subtitle fields may include "smart text" which lets you personalize push notifications for each recipient. Smart text uses a special format for placeholders which are substituted with the actual data at the time when a push notification is published based on a template. These placeholders identify data in the Backendless database as it relates to users receiving the notification. For example, the smart text in the example below will create a personalized greeting containing user's name:

message-smart-text

Text of the message is "Hello {Users.name}", where the {Users.name} part is the placeholder which will be substituted with the actual value. The placeholder consists of two parts: table name - Users and the column name - name. Notice the name column in the Users table schema below. this is the column the smart text placeholder is referencing:

users-table-name-column

Important

Smart text can reference columns, including related columns, in the Users table only. Although this may sound like a limitation, there is an explanation why smart text can come only from the Users table and tables related to Users. When a push notification with smart text is constructed in Backendless, smart text is resolved in the context of the device the push notification will be delivered to. These devices are stored in the DeviceRegistration table, which contains information about devices registered to receive push notification. A device may have a relation to a user, if the device registered after the user logged-in in the app. As a result, when Backendless identifies a device identified in the push template audience (see the Notification Audience section), it can retrieve information about the related user to populate the smart text placeholders.

If the Users table has a relation column pointing to another table, such as the address column in the screenshot above, it is possible to create smart text referencing it as well. For example, the smart text below references a table related to the Users table:
message-smart-text-related

In the example above the smart text is {Users.address.cityName}. The address part is the column name for a related table, while cityName is a column name in the related table.

The smart text can be typed as you edit the content or, alternatively, Backendless Console provides a visual smart text builder. Click the add smart text link to open the Smart Text popup:

smart-text-popup

The bottom part of the popup contains a drop-down list of all columns in the Users table. When you select a column and click the INSERT button, the smart text for the column is inserted into the message content located above. The smart text placeholder is inserted into the position where the cursor is placed. If the cursor is not active in the message content, the smart text placeholder is placed at the end of the content.

The drop-down with the column names also contains related columns. If you select a related column, another drop-down appears with a list of columns from the related table. There is no limit for the number of nested relations when composing smart text placeholders. For example, the screenshot below demonstrates selection of a relation column in the Users table (the address column) and a listing of the columns in the related table.

Message Headers

Message headers arrive to a device in the push notification payload and are not displayed by default. Apps use headers primarily for custom processing in the application code. Consider the following header setup:

sample-message-header

The following code demonstrates how to retrieve the value for the sample_header_name header:

// if retrieving in a button handling activity:
Intent intent = this.getIntent();
String headerValue = intent.getStringExtra( "sample_header_name" );
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    NSLog(@"Header value: %@", [userInfo valueForKey:@"sample_header_name"]);
    completionHandler(UIBackgroundFetchResultNewData);
}
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    print("Header value: \(userInfo["sample_header_name"] ?? "NONE")")
    completionHandler(.newData)
}