https://github.com/pradel/ionic-push
A node client for pushing android and ios notifications to your ionic app.
https://github.com/pradel/ionic-push
Last synced: 5 months ago
JSON representation
A node client for pushing android and ios notifications to your ionic app.
- Host: GitHub
- URL: https://github.com/pradel/ionic-push
- Owner: pradel
- License: mit
- Created: 2016-03-16T22:46:35.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-03-01T12:47:13.000Z (over 9 years ago)
- Last Synced: 2025-10-10T11:33:32.554Z (9 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://badge.fury.io/js/ionic-push)
[](https://travis-ci.org/pradel/ionic-push)
[](https://david-dm.org/pradel/ionic-push)
[](https://david-dm.org/pradel/ionic-push#info=devDependencies)
# ionic-push
A node client for pushing android and ios notifications to your ionic app.
## Install
`npm install --save ionic-push`
## Usage
```javascript
import IonicPush from 'ionic-push';
const ionic = new IonicPush(myJwt, myProfile);
ionic.push({
"tokens": ["your", "device", "tokens"],
"notification": {
"title": "Hi",
"message": "Hello world!",
"android": {
"title": "Hey",
"message": "Hello Android!"
},
"ios": {
"title": "Howdy",
"message": "Hello iOS!"
}
}
});
```
require
```javascript
var IonicPush = require('ionic-push').default;
var ionic = new IonicPush(myJwt, myProfile);
```
## Api
### new IonicPush
Create a new IonicPush instance.
#### Arguments
* `jwt` **string** _required_ [A valid ionic jwt](http://docs.ionic.io/v2.0.0-beta/docs/api-getting-started
)
* `profile` **string** _required_ [A valid ionic profile](http://docs.ionic.io/v2.0.0-beta/docs/security-profiles)
* `options` **object** _optional_ Options object.
* `options.Promise` **promise** _optional_ Promise to overwrite for requests.
##### Returns
An IonicPush instance.
##### Example
```javascript
import IonicPush from 'ionic-push';
const ionic = new IonicPush(myJwt, myProfile);
```
### testToken
Test if your token is valid.
##### Returns
A Promise.
#### Example
```javascript
ionic.testToken().then(function() {
console.log('my token is ok');
}).catch(function(err) {
console.log('there is an error', err);
});
```
### push
Push a new notification.
#### Arguments
* `options` **object** _required_ [A valid ionic push object](http://docs.ionic.io/v2.0.0-beta/docs/push-sending-push#section-basic-api-usage)
##### Returns
A Promise.
#### Example
```javascript
ionic.push({
"tokens": ["your", "device", "tokens"],
"notification": {
"title": "Hi",
"message": "Hello world!",
"android": {
"title": "Hey",
"message": "Hello Android!"
},
"ios": {
"title": "Howdy",
"message": "Hello iOS!"
}
}
}).then(function() {
console.log('successfully sent push');
}).catch(function(err) {
console.log('there is an error', err);
});
```
### checkStatus
Check the status of a notification.
#### Arguments
* `uuid` **object** _required_ [A valid ionic push uuid](http://docs.ionic.io/v2.0.0-beta/docs/push-sending-push#section-checking-the-status-of-a-push)
##### Returns
A Promise.
#### Example
```javascript
checkStatus(myuuid).then(function(data) {
console.log(data);
}).catch(function(err) {
console.log('there is an error', err);
});
```