GithubHelp home page GithubHelp logo

jonathangomz / onesignal-client Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 62 KB

Client for OneSignal API

Home Page: https://www.npmjs.com/package/@jonathangomz/onesignal-client

JavaScript 100.00%
onesignal client-api nodejs npm-package npm onesignal-api

onesignal-client's Introduction

OneSignal Client for Nodejs

A OneSignal client that implement some of the endpoints from the OneSignal API

Docs

Note: The responses are the direct responses from the provider so you can see the examples on his documentation (See ref).

constructor({ authKey, restApiKey, appId })

Creates a new OneSignal client.

const client = new OneSignal({
  authKey: process.env.AUTH_KEY,
  restApiKey: process.env.REST_API_KEY,
  appId: process.env.APP_ID,
});

isValid(): Promise<boolean | Error>

Validate that the app exist in the provider.

client.isValid()

getApp(): Promise<Response>

View the details of a single OneSignal app.

See more

Usage example:

client.getApp()

sendNotification(message, options?): Promise<Response>

Sends notifications to your users.
If attribute included_segments not provided will send to "Test" segment by default.

See more

Usage example:

const message = {
  heading: {
    en: 'Example Explicit Segment',
    es: 'Ejemplo Segmento Explicito',
  },
  content: {
    en: 'This is an example for Test segment explicitly',
    es: 'Este es un ejemplo para el segmento Test de forma explícita',
  }
}

const opt = {
  targets: {
    to: {
      type: 'external',
      value: ['1130745'],
    }
  }
}

client.sendNotification(message, opt);

cancelNotification(notification_id): Promise<Response>

Stop a scheduled or currently outgoing notification.

See more

Usage example:

client.cancelNotification('fd1723c6-bfaf-4f53-b4f4-0408ff43e18a');

viewNotifications(options?): Promise<Response>

View the details of multiple notifications.

See more

Usage example:

client.viewNotifications({ limit: 5 });

viewNotification(notification_id): Promise<Response>

View the details of a single notification and outcomes associated with it.

See more

Usage example:

client.viewNotification('fd1723c6-bfaf-4f53-b4f4-0408ff43e18a');

viewDevices(options?): Promise<Response>

View the details of multiple devices in your app.

See more

Usage example:

client.viewDevices({ limit: 2 });

viewDevice(player_id): Promise<Response>

View the details of an existing device in your OneSignal apps.

See more

Usage example:

client.viewDevice('fd1723c6-bfaf-4f53-b4f4-0408ff43e18a');

Ref:

https://documentation.onesignal.com/reference

onesignal-client's People

Contributors

jonathangomz avatar

Watchers

 avatar  avatar

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.