sails-service-pusher
Service for Sails framework with Pusher features.
List of supported pusher services
- APNS (Apple Push Notification Service)
- GCMS (Google Cloud Messaging Service)
Getting Started
Install this module.
npm install sails-service-pusher
Then require it in your service and create pusher instance.
// api/services/PusherService.js; 'ios' provider: cert: 'cert.pem' key: 'key.pem' production: false ; // api/controllers/PusherController.js { PusherService ; };
Configuration
When you instantiate new instance via PusherService()
you can provide configuration object with 3 keys:
config.device
- {Array} Device tokens that should get notification (will be merged with another devices insend()
)config.provider
- {Object} Options that will go to each of SDKs (APN, GCM)config.notification
- {Object} Options that will go to each of notifications (it has one interface for each of providers, see below)
API
Each of Pusher instances has only one method:
send([device], [notification], [config])
Sends Push Notification.
device
- {Array} Device tokens (registration IDs) to which push need to send (mixed up with pre-defined devices).
notification
- {Object} Config for notification:
notification.title
- Notification titlenotification.body
- Notification body textnotification.icon
- Notification iconnotification.sound
- Notification sound to be playednotification.badge
- Indicates the badge on client app home iconnotification.payload
- Custom data to send within Push Notification
config
- Additional configuration for notification with specific platform. See appropriate documentation.
Examples
APNNotification
All of this examples contains all the configuration keys. And most of them is optional.
let ios = ; ios ;
GCMNotification
let android = ; android ;
License
The MIT License (MIT)
Copyright (c) 2015 Eugene Obrezkov
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.