Removes shared code in PushAdapter, replaces AdapterLoader.load by loadAdapter

This commit is contained in:
Florent Vilmart
2016-02-22 18:31:10 -05:00
parent 8ce8e2bbe0
commit 48dcfe37e7
9 changed files with 97 additions and 84 deletions

View File

@@ -3,6 +3,8 @@
// PushAdapter, it uses GCM for android push and APNS
// for ios push.
import { classifyInstallations } from './PushAdapterUtils';
const Parse = require('parse/node').Parse;
var deepcopy = require('deepcopy');
import PushAdapter from './PushAdapter';
@@ -25,7 +27,7 @@ export class OneSignalPushAdapter extends PushAdapter {
send(data, installations) {
console.log("Sending notification to "+installations.length+" devices.")
let deviceMap = PushAdapter.classifyInstallation(installations, this.validPushTypes);
let deviceMap = classifyInstallations(installations, this.validPushTypes);
let sendPromises = [];
for (let pushType in deviceMap) {
@@ -43,6 +45,14 @@ export class OneSignalPushAdapter extends PushAdapter {
return Parse.Promise.when(sendPromises);
}
static classifyInstallations(installations, validTypes) {
return classifyInstallations(installations, validTypes)
}
getValidPushTypes() {
return this.validPushTypes;
}
sendToAPNS(data,tokens) {
data= deepcopy(data['data']);