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:

[code language=”JavaScript” title=”Sending push notification from Server Code:”]
PN.send("07a6350d-d563-3902-9aba-589ca6ab7876", {
"message": "Hi, there!")
});
[/code]

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

Discover more from Max Katz

Subscribe now to keep reading and get access to the full archive.

Continue reading