Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for push time #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# parse-server-onesignal-push-adapter
# parse-server-onesignal-push-adapter-scheduled-push-version

[![Build Status](https://travis-ci.org/parse-server-modules/parse-server-onesignal-push-adapter.svg?branch=master)](https://travis-ci.org/parse-server-modules/parse-server-onesignal-push-adapter)
[![codecov.io](https://codecov.io/github/parse-server-modules/parse-server-onesignal-push-adapter/coverage.svg?branch=master)](https://codecov.io/github/parse-server-modules/parse-server-onesignal-push-adapter?branch=master)



OneSignal push adapter for parse-server
OneSignal push adapter for parse-server that allows scheduled push notifications

Forked from https://github.com/parse-server-modules/parse-server-onesignal-push-adapter


## Installation

```
npm install --save parse-server-onesignal-push-adapter
npm install --save parse-server-onesignal-push-adapter-scheduled-push-version
```

## Usage

```
var OneSignalPushAdapter = require('parse-server-onesignal-push-adapter');
var OneSignalPushAdapter = require('parse-server-onesignal-push-adapter-scheduled-push-version');
var oneSignalPushAdapter = new OneSignalPushAdapter({
oneSignalAppId:"your-one-signal-app-id",
oneSignalApiKey:"your-one-signal-api-key"
Expand All @@ -29,4 +31,17 @@ var api = new ParseServer({
},
...otherOptions
});
```

To send schedule push notification, use the `push_time` option. For example:

```
Parse.Push.send({
channels: ['Default'],
data: {
alert: 'Alert!',
sound: 'www/beep.caf',
},
push_time: pushTime,
}
```
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "parse-server-onesignal-push-adapter",
"name": "parse-server-onesignal-push-adapter-scheduled-push-version",
"version": "1.0.0",
"description": "One Signal push adapter for parse-server",
"description": "One Signal push adapter for parse-server that allows scheduled push notifications",
"main": "lib/index.js",
"files": [
"lib/"
Expand All @@ -18,7 +18,7 @@
],
"repository": {
"type": "git",
"url": "git+https://github.com/parse-server-modules/parse-server-onesignal-push-adapter.git"
"url": "git+https://github.com/inoutput/parse-server-onesignal-push-adapter.git"
},
"author": "Parse",
"license": "MIT",
Expand All @@ -37,7 +37,7 @@
"parse-server-push-adapter": "^1.0.0"
},
"bugs": {
"url": "https://github.com/parse-server-modules/parse-server-onesignal-push-adapter/issues"
"url": "https://github.com/inoutput/parse-server-onesignal-push-adapter/issues"
},
"homepage": "https://github.com/parse-server-modules/parse-server-onesignal-push-adapter#readme"
"homepage": "https://github.com/inoutput/parse-server-onesignal-push-adapter#readme"
}
9 changes: 8 additions & 1 deletion src/OneSignalPushAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class OneSignalPushAdapter {
}

sendToAPNS(data,tokens) {

var pushTime = data['push_time'];
data= deepcopy(data['data']);

var post = {};
Expand All @@ -83,6 +83,9 @@ export class OneSignalPushAdapter {
delete data['background_data'];
delete data['content-available'];
}
if (pushTime) {
post['send_after'] = pushTime;
}
post['data'] = data;

let promise = new Parse.Promise();
Expand Down Expand Up @@ -118,6 +121,7 @@ export class OneSignalPushAdapter {
}

sendToGCM(data,tokens) {
var pushTime = data['push_time'];
data= deepcopy(data['data']);

var post = {};
Expand All @@ -138,6 +142,9 @@ export class OneSignalPushAdapter {
delete data['background_data'];
delete data['android_background_data'];
}
if (pushTime) {
post['send_after'] = pushTime;
}
post['data'] = data;

let promise = new Parse.Promise();
Expand Down