In all cases, for your application to receive notification you will need to subscribe to the topics, for which you have to use Push Notifications API.
A notification is a message that is displayed outside your app's UI to provide the user with reminders, communication from other people, or other timely information from your app. Users can tap the notification to open your app or take an action directly from the notification.
The most common parts of a notification are indicated in figure below:
1App Short Name: defined in publish settings
2App Icon: defined in publish settings
3Image: set in MessageData
4Title: set in MessageData
5Text: set in MessageData
Every notification open an appropriate app when tapped. In addition to this default notification action, you can add action buttons that complete an app-related task from the notification, as shown in figure below.
By default, the notification's text content is truncated to fit on one line. If you want your notification to be longer, you can enable a larger text area that's expandable by setting the text to long_text in MessageData.
You can also create an expandable notification with an image by setting the URL to large_image in MessageData. But, an expandable notification cannot have both fields large_image and long_text
You can send push notifications in either of the following ways:
From Fawi Office Notification menu without coding required for sending messages.
Or with more flexibility sending messages from your server by invoking Fawi Notifications APIs.
In all cases, for your application to receive notification you will need to subscribe to the topics, for which you have to use Push Notifications API.
This API is used to send push notifications.
Protocol: HTTPS
Method: POST
URL: https://push.fawiapis.com/send
Sending push notifications in this way the App Secret Key is needed for sending messages. For details about how to obtain the App Secret Key, please refer to Server Publish Settings.
PARAMETERS
Content-Type: application/json
Authorization: Bearer <app_secret_key>
The request body contains data with the following structure(JSON):
{ "validate_only"?: boolean, "message": { object(Message) } }
API request example
POST https://push.fawiapis.com/send HTTP/1.1
Content-Type: application/json
Authorization: Bearer your_app_secret_key
{
"validate_only": false,
"message":{
"to": "geral",
"data": {
"title": "New level",
"text": "Do you want to play now?",
"image": "https://www.example.com/data/806962_user.png",
"action_buttons": [{"label":"PLAY", "extra_info":"action_play"},
{"label":"DISMISS", "extra_info":"action_play"}]
}
}
}
The Message object contains the foolowin stucture:
{ "to": string, "data": { object(MessageData) } }
The MessageData object contains the foolowin stucture:
{ "title": string, "text"?: string, "long_text"?: string, "image"?: string, "large_image"?: string, "extra_info"?: string, "action_buttons"?: { object(ActionButton)[3] } }
PARAMETERS
[required] title: string Notification title.
[optional] text: string Notification text.
[optional] long_text: string Notification long text for expandable notifications.
[optional] image: string HTTPS Notification image URL.
[optional] large_image: string HTTPS Notification large image URL for expandable notifications.
[optional] extra_info: string Extra data that will be sent to your app when the user opens the notification. These data can be obtained using the Intent API.
[optional] action_buttons: ActionButton[3] Array of ActionButton objects (max 3).
A notification can offer up to three action buttons that allow the user to respond quickly.
The ActionButton object contains the foolowin stucture:
{ "label": string, "extra_info": string }
PARAMETERS
label: string Button text
extra_info: object(MessageData) Extra data that will be sent to your app when the user opens the notification. These data can be obtained using the Intent API.
Your application server must evaluate the message response header and body to interpret the message response sent by the Notification API. Below describes the possible responses.
Response Header
200: Notification was successfully processed. The response body will contain more details about the status of the message.
400: Incorrect parameter.
401: Authentication failed.
500: Internal service error.
Response Body
{ "result": string, "message": string }
result: string "success" | "error".
message: string result description.