BluemixPushNotifications is a Node.js SDK for sending push notifications via Bluemix Push Notifications services.
npm install bluemix-push-notifications --save
var PushNotifications = PushNotifications;var Notification = Notification;
Initialize PushNotifications with details about your Bluemix Push Notifications service.
var myPushNotifications = PushNotificationsRegionUS_SOUTH "your-bluemix-app-guid" "your-push-service-appSecret";
Note: The first parameter in the initializer is the Bluemix region where the Push Notifications service is hosted. The three options are
null is supplied for the last 2 parameters, their values will be automatically retrieved from the Bluemix app's environment variables, provided that your Node.js app is bound to the Bluemix app.
Next, create the push notification that you want to broadcast by supplying the alert message you want displayed.
var notificationExample = "Testing BluemixPushNotifications";
An optional URL may be supplied with the alert.
You can specify which devices the notification should be sent to and customize the alert they receive.
// setTarget(deviceIds, platforms, tagNames)notificationExample;// setApnsSettings(badge, category, iosActionKey, sound, type, payload)notificationExample;// setGcmSettings(collapseKey, delayWhileIdle, payload, priority, sound, timeToLive)notificationExample;
Finally, send the Push notification.
Copyright 2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.