Nine Pedestrians Mesmerized
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

This package has been deprecated

Author message:

Deprecated. Please use the ibm-push-notifications (


0.3.1 • Public • Published


Build Status Build Status Codacy Badge Coverage Status


BluemixPushNotifications is a Node.js SDK for sending push notifications through the IBM Bluemix Push Notifications service.


npm install bluemix-push-notifications --save


  • Ensure that the following prerequisites are in place:

    var PushNotifications = require('bluemix-push-notifications').PushNotifications;
    var Notification = require('bluemix-push-notifications').Notification;
    var PushMessageBuilder = require('bluemix-push-notifications').PushMessageBuilder;


  1. Initialize PushNotifications with details about your Bluemix Push Notifications service.

    var myPushNotifications = new PushNotifications(PushNotifications.Region.US_SOUTH, "your-bluemix-app-guid", "your-push-service-appSecret");

    The first parameter in the initializer is the Bluemix region where the Push Notifications service is hosted. The four options are :

    • PushNotifications.Region.US_SOUTH
    • PushNotifications.Region.UK
    • PushNotifications.Region.SYDNEY and
    • PushNotifications.Region.FRANKFURT If 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.

    If you are using dedicated service, use overrideServerHost and add any of the bluemixRegion (bluemix region) value.

    PushNotifications.overrideServerHost = "YOUR_SERVICE_HOST";
    var myPushNotifications = new PushNotifications(PushNotifications.Region.US_SOUTH, "your-bluemix-app-guid", "your-push-service-appSecret");
  2. Create the push notification that you want to broadcast by supplying the alert message you want to be displayed. An optional URL may be supplied with the alert.

    var message = PushMessageBuilder.Message.alert("20% Off for you")
    var notificationExample =  Notification.message(message).build();


    You can specify which devices, users, platforms, tag-subscriptions the notification should be sent to and customize the alert they receive.

  3. Create the target. You can either set deviceIds or userIds or platforms or tagNames.

    The following code snippet uses platforms, same way you can do it for deviceIds(...) or userIds(...) or tagNames(...).

    var target = PushMessageBuilder.Target.platforms(
        [Notification.Platform.Apple, Notification.Platform.Google,
  4. Create the message as listed:

    var message = PushMessageBuilder.Message.alert("20% Off Offer for you")

    Functionality added for FirefoxWeb, ChromeWeb, SafariWeb, ChromeAppExtension and extra optional settings introduced for Apns and FCM.

  5. Set all the optional settings for platforms (APNs, FCM, Safari etc).

        //For APNs settings
        var apns = PushMessageBuilder.APNs.badge(1).interactiveCategory("Accept")
            .payload({ "alert" : "20% Off for you" }).titleLocKey("OFFER")
        /* Options style and lights are new optional settings added to FCM,
        / * If your require lights and style settings you can create style and lights objects as listed           
        var style = PushMessageBuilder.FCMStyle.type(Notification.FCMStyleTypes
            .BIGTEXT_NOTIFICATION).text("IBM Push").title("Big Text Notification").url("")
            .lines(["IBM", "Bluemix", "Big Text Notification"]).build();
        var lights = PushMessageBuilder.FCMLights.ledArgb(Notification.FCMLED.BLACK)
        //For FCM settings.
        //Also timetolive setting is provided which specifies how long (in seconds)
        //The message should be kept in FCM storage if the device is offline.
        var fcm = PushMessageBuilder.FCM.collapseKey("ping")
            .payload({ "alert" : "20% Off for you" })
        //For Safari. 
        //All the three settings are mandatory to provide.
        var safariWeb = PushMessageBuilder.SafariWeb.title("IBM").urlArgs([""])
        //For Firefox
        var firefoxWeb = PushMessageBuilder.FirefoxWeb.title("IBM")
            .timeToLive(1.0).payload({ "alert" : "20% Off for you" }).build();
        //For ChromeAppExtension. 
        //You need to provide proper iconUrl or else chromeApp would not work.
        var chromeAppExt = PushMessageBuilder.ChromeAppExt.collapseKey("ping")
            .payload({ "alert" : "20% Off for you" }).build();
        //For Chrome
        var chromeWeb = PushMessageBuilder.ChromeWeb.title("IBM")
            .timeToLive(1.0).payload({ "alert" : "20% Off for you" }).build();
  6. Create settings with all platforms optional settings.

    var settings = PushMessageBuilder.Settings.apns(apns).fcm(fcm).safariWeb(safariWeb)
  7. Create final notification using target, settings, and message.

    var notificationExample = Notification.message(message)
  8. Send the Push notification.

    myPushNotifications.send(notificationExample, function(error, response, body) {
        console.log("Error: " + error);
        console.log("Response: " + JSON.stringify(response));
        console.log("Body: " + body);


Copyright 2017 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.



npm i bluemix-push-notifications

Downloadsweekly downloads









last publish


  • avatar
  • avatar
  • avatar