GithubHelp home page GithubHelp logo

scoutforpets / node-onesignal Goto Github PK

View Code? Open in Web Editor NEW
34.0 3.0 11.0 13 KB

Node.js wrapper for the One Signal API

License: MIT License

JavaScript 100.00%
push-notifications nodejs onesignal

node-onesignal's Introduction

OneSignal SDK for Node.js Build Status

This is an unofficial Node.js SDK for the OneSignal Push Notification Service, which wraps their REST API.

Basic Usage

// require the module
const OneSignalClient = require('node-onesignal');

// create a new clinet
const client = new OneSignalClient([YOUR APP ID], [YOUR REST API KEY]);

// send a notification
client.sendNotification('test notification', {
    included_segments: 'all'
});

API

OneSignalClient(appId, restApiKey)

  • appId(string, required) - your OneSignal App ID

  • restApiKey(string, required) - your OneSignal REST API Key

sendNotification(message, options)

  • message(string/object, required) - the content of your message. Note: when passing an object, please see the OneSignal documentation for details on the format.

  • options(object) - OneSignal options. Please see the OneSignal documentation.

As you can see, this SDK does not implement all of the methods available through the OneSignal REST API. If there are other methods you require, please open an issue or feel free to create a PR (with tests!).

Contributing

Just open a PR and include tests. Any help is greatly appreciated!

node-onesignal's People

Contributors

jamesdixon avatar lieuwex avatar mloureiro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-onesignal's Issues

Update package to add Cbabel-runtime/regenerator

Hey guys, it crashes when I start my api with your lib.

The error message:
Cannot find module 'babel-runtime/regenerator'

It points directly to this line:
var OneSignalClient = require('node-onesignal');

No notification being received.

I am able to push notifications to my machine from OneSignal.com, however I do not receive them when I call the sendNotification function.

console.log('sending');
const OneSignalClient = require('node-onesignal').default;
const client = new OneSignalClient('1111111', '222222');
client.sendNotification('test notification', {
    included_segments: 'all'
});

The 'sending' string is logged but I do not receive any notifications, errors, or send requests on onesignal.com

My node version is 6.110

TypeError: apickli.Apickli is not a constructor

Hi,

I am getting error : TypeError: apickli.Apickli is not a constructor when i am trying to use Sendpostrequest .js again in my next step in a scenario.
Below is the code i am using.
From A.js i am trying to call Sendpostrequest for first step its working fine but when i am using it again i am getting error TypeError: apickli.Apickli is not a constructor

A.js
Sendpostrequest(obj.domain, obj.requestheader, querystring.stringify(obj.requestbody))

Sendpostrequest .js

'use strict';
const querystring = require('querystring');
let apickli = require('apickli');

const Sendpostrequest = (requesturl, header,body)=>{
apickli = new apickli.Apickli('https', requesturl);
for(let key in header) {
apickli.addRequestHeader(key,header[key]);
}

console.log("Header ------------->>>>>>>>>>>", header);
console.log("Url------------->>>>>>>>",requesturl);
//console.log("1 test >>>>>>>>>", header);
if(body){
apickli.setRequestBody(body);
}
return new Promise((resolve,reject)=>{
apickli.post('',function(error, response) {
if (error) {
return reject(error);
}

        return resolve(response);
    });
})

}
module.exports = Sendpostrequest;

TypeError: OneSignalClient is not a constructor

> root@ip-172-31-41-200:/usr/share/nginx/html/webapps/node_modules/node-onesignal/dist# node
> var OneSignalClient = require('node-onesignal');
undefined
> var client = new OneSignalClient('1', '2');
TypeError: OneSignalClient is not a constructor
    at repl:1:14
    at ContextifyScript.Script.runInThisContext (vm.js:23:33)
    at REPLServer.defaultEval (repl.js:339:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.onLine (repl.js:536:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:191:7)
    at REPLServer.Interface._onLine (readline.js:241:10)
    at REPLServer.Interface._line (readline.js:590:8)
> 

Node version is

# node --version
v7.10.0
#

Any idea how to fix this error ?

EDIT: i tried on v8.0.0, got same error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.