This article shows how you can write RHMAP Cloud Apps to perform push notifications to:
- All devices subscribed to a ‘category’, enabling the possibility of users choosing the notification categories they find interesting.
- A specific group of users, providing efficient communication with a defined set of users.
With RHMAP, it is simple to deliver a notification to a set of users/devices based on category. For example, if your app reports sports results, you can filter the results to only send notifications relating to your favorite sports categories as follows:
const message = { alert: "Hello from Cloud App to sports fans!", sound: "default" }; const options = { criteria: {} }; options.criteria = { categories: [“Curling”,”Hockey”] }; $fh.push(message, options, () => { console.log("All Curling and Hockey fans notified!"); });
If you want to deliver a notification to a list of specific recipient aliases, use the following code to send the notification to a group of up to ten recipients at a time:
const listOfAlias = ["ceo@company.com", "cto@company.com", "cfo@company.com", "cio@company.com"]; const message = { alert: "Hello from Cloud App to the famous four", sound: "default" }; const options = { criteria: {} }; options.criteria = { alias: listOfAliases }; $fh.push(message, options, () => { console.log("All aliases notified!"); });
Note: When registering with the server, Client Apps report an alias, such as a user name or an e-mail representing a single person (with possibly multiple devices).
Last updated: October 31, 2023