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

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

servercode_push

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.