Chapter 6. $fh.push
$fh.push(message, options, callback(err, res))
Send a push message from the cloud to registered clients.
6.1. Example
Push a message to all devices in all Client Apps of the associated project
var message = {
alert: "hello from FH"
}, options = {
broadcast: true
};
$fh.push(message, options,
function (err, res) {
if (err) {
console.log(err.toString());
} else {
console.log("status : " + res.status);
}
});
Push a message for specific deviceType in a specific Client App
var message = {
alert: "hello from FH"
},
options = {
apps: ["3uzl1ebi6utciy56majgqlj8"], // list of App IDs
criteria: {
deviceType: "android"
}
};
$fh.push(message, options,
function (err, res) {
if (err) {
console.log(err.toString());
} else {
console.log("status : " + res.status);
}
});
6.2. Example Silent Push (iOS only)
Cloud App Example:
var message = {
'apns' : {
'contentAvailable' :1
}
};
var options = {
broadcast: true,
};
$fh.push(message, options, function (err, res) {
if (err) {
console.log('Push error:' + err.toString());
} else {
console.log("status from Unified Push : " + util.inspect(res));
}
});
Client App (Cordova) Example:
onNotification: function (event) {
// content-available: 1 means Silent Notification
if (event['content-available'] === 1) {
//get the content and inform about the result
var push = window.push;
// call the fetchCompletionHandler not to terminate this app.
push.setContentAvailable(push.FetchResult.NewData);
}
}
Example of Log Output:
Sep 21 11:00:19 device_name SimpleCordovaPushApp[2192] <Warning>: Background Fetch Sep 21 11:00:19 device_name SimpleCordovaPushApp[2192] <Warning>: didReceiveNotification Sep 21 11:00:19 device_name SimpleCordovaPushApp[2192] <Warning>: Notification received
6.3. Parameters
6.3.1. Notification
messageObject-
alertString — The main message -
soundString — The name of a sound file in the app bundle, ordefault -
badgeString — The number to display as the badge of the app icon -
userDataObject — Any extra user data to be passed
-
For iOS, the sound triggers when the push notification is delivered to the client device. For Android, it triggers when the push notification is opened on the client device.
6.3.2. iOS-specific
message.apnsObject — Options specific to the Apple Push Notification Service-
titleString — A short string describing the purpose of the notification -
actionString — The label of the action button -
urlArgsArray — (Safari only) Values that are paired with the placeholders inside the urlFormatString value of your website.json file -
titleLocKeyString — (iOS only) The key to a title string in the Localizable.strings file for the current localization -
titleLocArgsArray — (iOS only) Variable string values to appear in place of the format specifiers in title-loc-key -
actionCategoryString — The identifier of the action category for the interactive notification -
contentAvailableNumber — (iOS only) Informs the application that new content is available by delivering a silent notification. The only possible value is1.
-
6.3.3. Other configuration
-
optionsObject options.configObject-
ttlNumber — (APNS and GCM only) The time to live in seconds.
-
6.3.4. Selection of Client Apps in project
One of the options — broadcast or apps — must be set manually, there is no default value.
-
options.broadcastBoolean — when set totrue, notification will be sent to all Client Apps in the project which contains the sending Cloud App -
options.appsArray — list of Client App IDs to send the notification to
6.3.5. Filtering recipients
options.criteriaObject — Criteria for selection of notification recipients.
See Sending Notifications for details about these criteria.-
aliasArray — list of user-specific identifiers -
categoriesArray — list of categories -
deviceTypeArray — list of device types -
variantsArray — list of variant IDs
-
6.3.6. Response handling
-
callback(err, res)Function — callback invoked after the message is pushed to the integrated push server. Iferris set, it contains any possible error response. Parameterrescontains the normal server response.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.