Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Notification payload support

Roman Savin edited this page Jul 22, 2015 · 2 revisions

The OPFPush library supports notification messaging. The mechanism is similar to GCM Notification payload support.

The NotificationMaker interface was added to OPFPush for customizing notifications. You can add an instance of your own implementation for a push provider in a constructor. The default implementation which is used in BasePushProvider is OPFNotificationMaker. To send a push message which is handled as a notification payload you must add to your data the opf_notification field which must has true value. Also, you have to add the same parameters as for GCM notification messages.

Parameters for notification messaging by platform:

  • opf_notification (required) - If it has true value the other parameters will be used for building notification. If a parameter don't belong to this list it will be ignored.
  • title (required) - Indicates notification title.
  • body (optional) - Indicates notification body text.
  • icon (required) - Indicates notification icon. Sets value to myicon for drawable resource myicon.png.
  • sound (optional) - Indicates sound to be played. Supports only default currently.
  • badge (optional) - Indicates the badge on client app home icon.
  • tag (optional) - Indicates whether each notification message results in a new entry on the notification center on Android. If not set, each request creates a new notification. If set, and a notification with the same tag is already being shown, the new notification replaces the existing one in notification center.
  • color (optional) - Indicates color of the icon, expressed in #rrggbb format.
  • click_action (optional) - The action associated with a user click on the notification.

You can use OPFNotificationMaker with your own implementation of the NotificationPreparer interface. You must implement the prepare(Bundle) method. It must convert the bundle argument to an instance of NotificationPayload. The bundle argument contains data parameters which are received by push provider. So you just get parameters for notification by your own keys and build a NotificationPayload object which is used for creating a notification.

Clone this wiki locally