npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ibm-push-notification

v0.1.1

Published

create a remote notification payload and sends it to Android / iOS servers

Downloads

4

Readme

IBM Push Notification (Hybrid [iOS and Android]) [WiP]

This module will allow you to send push notification to iOS and Android devices without depending from other stuff.

This module aren't finished yet, we are building / testing it the usage is not recommended

Prerequisite

Since this module uses features available after Node7, it is required of the module usage, so we decide to put the version used to build this module as starter:

  • Node 7.10.0 or higher;

Dependencies

Since this module communicate with other server it will install the module below:

  • request@2.81.0

Installation

npm install ibm-push-notification

Parameters

Initialization

Here follow the params used on the client initialization

| Property | Type | Required | Description | ---------- | ------- | ---------------- | ----------- | ios     | Object | True | Holds the initilization parameters used on iOS | android    | Object | True | Holds the initilization parameters used on Android

Notification

The notification parameters will be the same defined on iOS / Android individually (but since iOS has more parameters than android, consider to use iOS model):

  • iOS
  • Android

Usage

This module allow you to work with both notifications or if you are working with just one platform (android/ios) you can require just what u

  • iOS
  • Android
  • Hybrid, just keep reading :D

Create the client

Below you can see several different ways to create your push client

//Read the ios readme for more details about possibilities when initializing a client.
const ios = {
    p12: '/path/to/Certificate.p12',
    password: 'test',
    bundle: 'com.yourapp.bundle'
}
const android = {
    key: 'here-goes-your-google-client-key'
}

const PushNotification = require('ibm-push-notification')({ ios, android })

Send the Push Notification

After create the client for the push notification, you can send it anytime following the examples below:

One device only

Here is an example about how to send the notification to one device only

Only Mandatory Params
const ios = {
    p12: '/path/to/Certificate.p12',
    password: 'test',
    bundle: 'com.yourapp.bundle'
}
const android = {
    key: 'here-goes-your-google-client-key'
}
const PushNotification = require('ibm-push-notification')({ ios, android })

async function sendNotification(message) {
    try {    
        return await PushNotification.send({
            notification: message
        }, { ios: <DEVICE_ID>, android: <DEVICE_ID> })
    } catch (err) {
        throw err
    }
}
Custom Properties
const ios = {
    p12: '/path/to/Certificate.p12',
    password: 'test',
    bundle: 'com.yourapp.bundle'
}
const android = {
    key: 'here-goes-your-google-client-key'
}
const PushNotification = require('ibm-push-notification')({ ios, android })

async function sendNotification(message) {
    try {    
        return await PushNotification.send({
            aps: { badge:3, sound:"bingbong.aiff" },
            notification: { title: "Foo", body: "Bar" },
            priority: 5,
            expiration: 0
        }, { ios: <DEVICE_ID>, android: <DEVICE_ID> })
    } catch (err) {
        throw err
    }
}

Multiple devices

Here is an example about how to send the notification to multiple devices (same message)

Only Mandatory Params
const ios = {
    p12: '/path/to/Certificate.p12',
    password: 'test',
    bundle: 'com.yourapp.bundle'
}
const android = {
    key: 'here-goes-your-google-client-key'
}
const PushNotification = require('ibm-push-notification')({ ios, android })

async function sendNotification(message) {
    try {    
        return await PushNotification.send({
            notification: message
        }, { ios: [<DEVICE_ID_1>, <DEVICE_ID_2>], android: [<DEVICE_ID_3>, <DEVICE_ID_4>] })
    } catch (err) {
        throw err
    }
}
Custom Properties
const ios = {
    p12: '/path/to/Certificate.p12',
    password: 'test',
    bundle: 'com.yourapp.bundle'
}
const android = {
    key: 'here-goes-your-google-client-key'
}
const PushNotification = require('ibm-push-notification')({ ios, android })

async function sendNotification(message) {
    try {    
        return await PushNotification.send({
            aps: { badge:3, sound:"bingbong.aiff" },
            notification: { title: "Foo", body: "Bar" },
            priority: 5,
            expiration: 0
        }, { ios: [<DEVICE_ID_1>, <DEVICE_ID_2>], android: [<DEVICE_ID_3>, <DEVICE_ID_4>] })
    } catch (err) {
        throw err
    }
}

Authors

  • Adriano - Initial Work - adrianopaladini
  • Night - Review and Improvements - niightly