hexo-deployer-onesignal

0.5.1 • Public • Published

hexo-deploy-onesignal

npm version npm dependencies npm dev dependencies npm download/month npm download total gitter chat

Plugin to send notification through Onesignal.com once hexo deploy is called.

Instalation

npm install --save hexo-deployer-onesignal

Now edit _config.yml and add this the deploy: section:

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy: 
   - type: onesignal
     app_id: abcdefab-ab34-1abc-c123456789ab

App_id is used to identify the app (as onesignal calls a notification site/mobile app) at onesignal.com, it is available at Keys & IDs tabs of "App Settings" menu. This UUID can be disclosed, it is no secret.

Onesignal also provides REST API Key which this plugin uses to access API server. It is kind a password and may be kept secret hence not recommended to keep it on _config.yml that is normally versioned on a public repository. But if site source has no public repository, it is possible to add app_auth_key: <REST API Key> to the deploy section above. For those who keep source on public repositories, an environment variable is the way to go:

export ONESIGNAL_APP_AUTH_KEY=<REST API Key>

Hexo will accept more than one deploy plugin, just add another -type: section:

# Deployment
## Docs: http://hexo.io/docs/deployment.html
deploy:
   - type: git
     repo: git@github.com:user/repo-name.git
     branch: gh-pages
   - type: onesignal
     app_id: abcdefab-ab34-1abc-c123456789ab

Options

-app_id Is the UUID of the Onesignal app to be notified.

-app_auth_key Is the API key provided by Onesginal to access API server, it should be kept secret.

-app_send_delay This shall be expressed in minutes (integer number) and will introduce a delay of n minutes before notification dispatch to subscribers. since this is a feature from Onesginal service it will not hold deployer for delay time.

Usage

The plugin is called by hexo when deploy option is used:

hexo deploy
INFO  Deploying: onesignal
INFO  Loading template /home/user/my-site/node_modules/hexo-deployer-onesignal/templates/all-segments-default.json
INFO  Deploy done: onesignal
INFO  Sending message
INFO  https response: { id: '89e1ba06-d9eb-4b83-b7f5-e46541825d8e', recipients: 2 }

Users subscribed to the site/app will receive notification. See Onesignal dashboard to analytics about subscribed users.

Notice

Site visitors need a interface to subscribe/unsubscribe notifications for a given hexo site. This guide teachs how.

Tranquilpeak theme for hexo has interface implemented at theme level. (not yet released at the time of this write, PR #396)

Readme

Keywords

Package Sidebar

Install

npm i hexo-deployer-onesignal

Weekly Downloads

1

Version

0.5.1

License

MIT

Last publish

Collaborators

  • jrbenito