A Quick Guide to Sending Push Notifications

Being able to send Push Notifications to users is one of the fundamental capability in an enterprise mobile app. Appery.io platform comes with Push Notifications component out-of-the-box and allows you quickly to send targeted messages to iOS and Android devices. In this blog post we will show the four ways to send a Push Notification message to a user:

  1. Push Notifications Console.
  2. Server Code Push Notifications API (server-side).
  3. Push Notification REST API.
  4. Customer Console.

Push Notifications Console

This first option is probably the simplest way to send a Push Notifications once you have installed an app on a device. Select device types, enter the message and send. The Push Notification message should arrive on the registered device instantly.

 

PN_console.png
Push Notifications console.

 

Server Code Push Notifications API (server-side)

With Push Notifications Console, you can quickly test sending a message. With the Server Code option, you can write server-side logic before or after the message is sent. Server Code script allows you to write server-side app logic using JavaScript, including API for sending push messages. For example, let’s say you want to query the database before sending a message. A script can also be scheduled to run periodically, for example, once in 24 hours. Using the previous example, the script can query the database for inventory. If the inventory is low, the script can send a Push Notification message to a manager, notifying him or her that the inventory is low.

The following Server Code scripts send a Push Notification message:

var pushApiKey = "72082f44-4798-4d69-9c35-74981646ec92";
Apperyio.PN.send(pushApiKey, {"message": "Hey there - inventory is low!"});

It takes one line of code to send a Push Notification message.

Push Notification REST API

Another option is to use Push Notifications REST API. A curl command to send a message:

curl -X POST
-H "X-Appery-Push-API-Key: 72082f44-4798-4d69-9c35-74981646ec92"
-H "Content-Type: application/json"
-d '{
  "payload":{
     "message":"Hey there!"
   },
  "status":"sent"
   }'
https://api.appery.io/rest/push/msg

For example, this API can be used from API Express when using the REST component. In the future, we will be adding native integration for Push Notifications in API Express. This will allow you to drop a component into the service flow to send a message.

Customer Console

The last option is to send a Push Notifications message from the Customer Console. The Customer Console is useful when you are building an app for a customer and want the customer to be able to edit the app data (in the database) and send Push Notification messages. For example, let’s say you build an app for a store owner and she wants to send a Push Notification message with a coupon to all users. She can login into the app’s Customer Console and send a Push Notification.

Summary

With Appery.io built-in Push Notifications component, sending messages to all users (devices) or targeted messages is simple and flexible. Check out our YouTube channel to learn more.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s