Push notifications

The K2 Business Apps broker now has various notification related methods that allow you to send push notifications to one or more users that have been registered for these notifications. These registrations can be found in the K2 Business Apps database on the server, in the tables Users and Devices. A user is someone that logged in once and can have zero or more devices registered for push notifications. (Zero if the user did not allow push notifications.) Next to individual users, we have topics. A topic is a group of users that has a name. These topics are not predetermined, but can be created as you desire. In the remainder of this article, we’ll use the term target for either users or topics.

Before we look at the methods available, we will explain the three types of notifications K2 Business Apps supports:

Normal

A normal notification is your average notification. It holds a title and target and can optionally set a body and color. These types of notifications will show up in your operating system if the app is not running in the foreground. The notification in your OS will always show a generic K2 Business Apps icon, the title and when provided, the body. When the app is open, the notification can be found on the page notifications. Here you’ll see the message as well as the color, if provided. When the color is not provided, the theme’s accent color is used. Clicking the notification here acts as if a notification in the operating system was clicked.

Silent

A silent notification will not show in your operating system, but only in the app. This type of message was created so you can send lots of messages to someone without their device continuously ringing. The in-app functionality and layout is identical to that of the normal notifications.

Hidden

A hidden notification is, as the name suggests, not visible to the user. It will not show in the OS, nor in the app. These types of notifications are used to send an action to a user. These actions are described with the service broker methods.

Service broker methods

The methods are listed below, but first we’ll look at the possible input properties you’ll encounter. As some of them are available on most methods, they will be listed first.

Input Properties:

  • Body

    The body of the notification.

  • Color

    A hexadecimal string representing a color.

  • Event Name

    The name of the event in the workflow in which the task is created. This is used to filter the tasks, as one workflow can create multiple tasks in various stages of the workflow.

  • Process ID

    The process ID is also known as the workflow ID.

  • Silent

    When set to yes, the notification becomes a silent one.

  • Title

    The title of the notification.

  • Topic(s)

    A semi-colon separated list of topic IDs to which this notification will be send.

  • User(s)

    A semi-colon separated list of FQNs to which this notification will be send.

Send Notification For New Tasks

This sends a normal notification to the users that get a new task within the next 10 seconds. This method can be called right before the tasks are created in a workflow.

Send Notification To Topic(s) / User(s)

This sends a basic notification to one or more targets. It is just a message without any action taken when it is clicked.

Send Open Form Notification To Topic(s) / User(s)

When one of these messages is clicked, the app will open the provided form, given the user has permission to access this form. You can optionally provide parameters that will be set when the form is opened.

Send Popup Notification To Topic(s) / User(s) / (Hidden)

When this message is clicked, the app will show a popup message with the same title and body. When send as a hidden message, the user has no choice but to see the message.

Send Refresh App Items Notification To Topic(s) / User(s) / (Hidden)

Clicking these notifications result in the app moving to the app page and performing a pull down to refresh, resulting in the app items being checked. This can be useful when you change a user’s permissions. When send as a hidden notification, the app will refresh the app items, whether the user wants it or not.

Send Refresh Task List Notification To Topic(s) / User(s) / (Hidden)

When this message is clicked, the app moves the user to the task page and performs a pull down to refresh, resulting the both the app items and task being checked. When send as a hidden notification, the app will refresh the app items and tasks, whether the user wants it or not.