How to Send a Push Notification from Server Code Script in One Line of Code

Appery.io Server Code allows to quickly write any custom app logic using JavaScript and expose is via a REST API. Here is an example invoking Uber API, and example accessing the cloud database and scheduling the script to run periodically.

Screen Shot 2015-10-28 at 9.33.31 PM
Sending push message

The Server Code script JavaScript API also enables you to send a push notification in just one line of code (well, 3 lines of code). After you configure push notifications, this is how to send a message to all users who installed the app:

PN.send("07a6350d-d563-3902-9aba-589ca6ab7876", {
    "message": "Hi, there!")
  });

Once you configure push, you will have a Push API key which you set above and then just the push message. This code will send a message to all the users who installed the app. There is also an option to send a targeted push message, only to some users.

Any script is automatically exposed via a REST API so you can quickly invoke it from an app. If you need to customize your app and build custom APIs – Server Code script is what you need.

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