
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
pushwoosh-client
Advanced tools
A node js client to consume the Pushwoosh API to send push notifications to mobile devices
A node js client to consume the Pushwoosh API to send push notifications to mobile devices
npm i pushwoosh-client --save
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh("AppCode", "AuthToken");
client.sendMessage('Hello world', function(error, response) {
if (error) {
console.log('Some error occurs: ', error);
}
console.log('Pushwoosh API response is', response);
});
To send messages to a specificed device or devices, you can pass a device token or an arrays with devices
// Push to a device
client.sendMessage('Hello world', 'device token', function(error, response) {
...
});
// Push to multiple devices
client.sendMessage('Hello world', ['deviceToken1', 'deivceToken2'], function(error, response) {
...
});
To pass extra options (please refer to the Pushwoosh doc for the available options) , you could define an option object and pass it to the function as a 2nd or 3rd parameter. E.g. if you want to pass addtional payload to the device, you could do:
var Pushwoosh = require('pushwoosh-client'),
client= new Pushwoosh("AppCode", "AuthToken"),
options = {
data: {
username: 'bob smith',
email: 'bob@example.com'
}
};
client.sendMessage('Hello world', 'device token', options, function(error, response) {
...
});
Note that if you define devices or content in the options, the devices and message will be overwritten.
var options = {
data: {
username: 'bob smith',
email: 'bob@example.com'
},
devices: ['deviceToken1', 'deviceToken2', 'deviceToken3']
};
client.sendMessage('Hello world', 'device token', options, function(error, response) {
...
});
Then this will send to ['deviceToken1', 'deviceToken2', 'deviceToken3'] as defined in options. so you probably just want to just do
client.sendMessage('Hello world', options, function(error, response) {
...
});
To use Puswoosh applications_group
code(which allows you to send to multilple applications) instead of application
code, you must pass a third options
argument when creating the client with useApplicationsGroup
set to true:
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh("AppsGroupCode", "AuthToken", {
useApplicationsGroup: true,
...
});
// Will push using "applications_group":"AppsGroupCode" for all of the explained invocation patterns
client.sendMessage('Hello world', function(error, response) {
...
});
// or
client.sendMessage('Hello world', options, function(error, response) {
...
});
// ... and so on
To register a device's push token in Pushwoosh:
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh('AppCode', 'AuthToken');
var registerDeviceOptions = {
push_token: 'pushtoken',
hwid: 'hwid',
device_type: 3,
language: 'en', // optional, two-letter code ISO-639-1
timezone: -3600 // optional, offset in seconds
};
// this will register the device for the client's 'AppCode' application
client.registerDevice(registerDeviceOptions, function(error, response) {
...
});
To unregister a device in Pushwoosh:
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh('AppCode', 'AuthToken');
var unregisterDeviceOptions = {
hwid: 'hwid'
};
// this will unregister the device from the client's 'AppCode' application
client.unregisterDevice(unregisterDeviceOptions, function(error, response) {
...
});
To set tags for a device in Pushwoosh:
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh('AppCode', 'AuthToken');
var setTagsOptions = {
hwid: 'hwid',
tags: {
price: "1.99",
language: "pl"
}
};
// this will set the device tags for the client's 'AppCode' application
client.setTags(setTagsOptions , function(error, response) {
...
});
To get tags for a device from Pushwoosh:
var Pushwoosh = require('pushwoosh-client');
var client= new Pushwoosh('AppCode', 'AuthToken');
var getTagsOptions = {
hwid: 'hwid'
};
// this will get the device tags for the client's 'AppCode' application
client.getTags(getTagsOptions , function(error, response) {
...
});
npm test
Currently tests are all passed and with 100% coverage
FAQs
A node js client to consume the Pushwoosh API to send push notifications to mobile devices
The npm package pushwoosh-client receives a total of 170 weekly downloads. As such, pushwoosh-client popularity was classified as not popular.
We found that pushwoosh-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.