create a remote notification payload and sends it to Android / iOS servers
npm install ibm-push-notificationThis 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__
* Node 7.10.0 or higher;
Since this module communicate with other server it will install the module below:
``npm install ibm-push-notification`
#### 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
* Hybrid, just keep reading :D
#### Create the client
Below you can see several different ways to create your push client
`javascript
//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 })
`
#### One device only
Here is an example about how to send the notification to one device only
###### Only Mandatory Params
`javascript
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:
} catch (err) {
throw err
}
}
`
###### Custom Properties
`javascript
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:
} catch (err) {
throw err
}
}
`
#### Multiple devices
Here is an example about how to send the notification to multiple devices (same message)
###### Only Mandatory Params
`javascript
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: [
} catch (err) {
throw err
}
}
`
###### Custom Properties
`javascript
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: [
} catch (err) {
throw err
}
}
``
Adriano - Initial Work* - !adrianopaladini
Night - Review and Improvements* - !niightly