Make push follow controller and adapter style
This commit is contained in:
@@ -7,16 +7,10 @@ const Parse = require('parse/node').Parse;
|
||||
const GCM = require('../../GCM');
|
||||
const APNS = require('../../APNS');
|
||||
|
||||
function ParsePushAdapter() {
|
||||
this.validPushTypes = ['ios', 'android'];
|
||||
this.senders = {};
|
||||
}
|
||||
function ParsePushAdapter(pushConfig) {
|
||||
this.validPushTypes = ['ios', 'android'];
|
||||
this.senders = {};
|
||||
|
||||
/**
|
||||
* Register push senders
|
||||
* @param {Object} pushConfig The push configuration which is given when parse server is initialized
|
||||
*/
|
||||
ParsePushAdapter.prototype.initialize = function(pushConfig) {
|
||||
// Initialize senders
|
||||
for (let validPushType of this.validPushTypes) {
|
||||
this.senders[validPushType] = [];
|
||||
|
||||
@@ -3,27 +3,15 @@
|
||||
// Allows you to change the push notification mechanism.
|
||||
//
|
||||
// Adapter classes must implement the following functions:
|
||||
// * initialize(pushConfig)
|
||||
// * getPushSenders(parseConfig)
|
||||
// * getValidPushTypes(parseConfig)
|
||||
// * getValidPushTypes()
|
||||
// * send(devices, installations)
|
||||
//
|
||||
// Default is ParsePushAdapter, which uses GCM for
|
||||
// android push and APNS for ios push.
|
||||
export class PushAdapter {
|
||||
send(devices, installations) { }
|
||||
|
||||
var ParsePushAdapter = require('./ParsePushAdapter');
|
||||
|
||||
var adapter = new ParsePushAdapter();
|
||||
|
||||
function setAdapter(pushAdapter) {
|
||||
adapter = pushAdapter;
|
||||
getValidPushTypes() { }
|
||||
}
|
||||
|
||||
function getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getAdapter: getAdapter,
|
||||
setAdapter: setAdapter
|
||||
};
|
||||
export default PushAdapter;
|
||||
|
||||
Reference in New Issue
Block a user