Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/faressoft/onesignal
A Wrapper for OneSignal Push Notification Delivery for Node.js. Provides the minimal functionality to send notifications for iOS and Android.
https://github.com/faressoft/onesignal
Last synced: 11 days ago
JSON representation
A Wrapper for OneSignal Push Notification Delivery for Node.js. Provides the minimal functionality to send notifications for iOS and Android.
- Host: GitHub
- URL: https://github.com/faressoft/onesignal
- Owner: faressoft
- License: mit
- Created: 2016-12-11T21:42:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-04-07T03:00:30.000Z (over 1 year ago)
- Last Synced: 2024-10-25T14:00:57.883Z (14 days ago)
- Language: JavaScript
- Size: 106 KB
- Stars: 20
- Watchers: 4
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OneSignal
[![npm](https://img.shields.io/npm/v/onesignal.svg)](https://www.npmjs.com/package/onesignal)
[![npm](https://img.shields.io/npm/l/onesignal.svg)](https://github.com/faressoft/onesignal/blob/master/LICENSE)
A Wrapper for OneSignal Push Notification Delivery for Node.js. Provides the minimal functionality to send notifications for iOS and Android.# Installation
```
npm install onesignal --save
```# Usage
```js
// Create a client object
var oneSignal = require('onesignal')('[apiKey]', '[appId]', true);
```## OneSignal(apiKey, appId, sandbox)
OneSignal Client| Param | Type | Description |
| --- | --- | --- |
| apiKey |String
| REST API Key |
| appId |String
| OneSignal App ID |
| sandbox |Boolean
| use the sandbox certificate for iOS (default: false) |## Methods
-
addDevice(identifier, osType) ⇒Promise
Register a new device and its identifier to OneSignal and get OneSignal ID
-
editDevice(oneSignalId, newIdentifier) ⇒Promise
Update the identifier of an existing device
-
createNotification(message, data, oneSignalIds) ⇒Promise
Create and send a notification
### addDevice(identifier, osType) ⇒ Promise
Register a new device and its identifier to OneSignal and get OneSignal ID.
**Returns**: Promise
- resolve with OneSignal ID
| Param | Type | Description |
| --- | --- | --- |
| identifier | String
| the device token |
| osType | String
| ios, android |
### editDevice(oneSignalId, newIdentifier) ⇒ Promise
Update the identifier of an existing device.
| Param | Type | Description |
| --- | --- | --- |
| oneSignalId | String
| the onesignal device id |
| newIdentifier | String
| the new device token |
### createNotification(message, data, oneSignalIds) ⇒ Promise
Create and send a notification.
| Param | Type | Description |
| --- | --- | --- |
| message | String
| the notification message |
| data | Object
| any custom data |
| oneSignalIds | Array
| a list of OneSignal devices ids |
# License
This project is under the MIT license.