[FIX] Multiple push notifications sent via native drivers (#18442)

pull/18457/head
Diego Sampaio 5 years ago committed by GitHub
parent f2683d1f94
commit 4ebe5283bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      app/push/server/apn.js
  2. 3
      app/push/server/gcm.js
  3. 3
      app/push/server/push.js

@ -1,4 +1,5 @@
import apn from 'apn';
import { EJSON } from 'meteor/ejson';
import { logger } from './logger';
@ -34,7 +35,7 @@ export const sendAPN = ({ userToken, notification, _removeToken }) => {
}
// Allow the user to set payload data
note.payload = notification.payload || {};
note.payload = notification.payload ? { ejson: EJSON.stringify(notification.payload) } : {};
note.payload.messageFrom = notification.from;
note.priority = priority;
@ -111,5 +112,10 @@ export const initAPN = ({ options, absoluteUrl }) => {
}
// Rig apn connection
apnConnection = new apn.Provider(options.apn);
try {
apnConnection = new apn.Provider(options.apn);
} catch (e) {
console.error('Error trying to initialize APN');
console.error(e);
}
};

@ -1,4 +1,5 @@
import gcm from 'node-gcm';
import { EJSON } from 'meteor/ejson';
import { logger } from './logger';
@ -21,7 +22,7 @@ export const sendGCM = function({ userTokens, notification, _replaceToken, _remo
logger.debug('sendGCM', userTokens, notification);
// Allow user to set payload
const data = notification.payload || {};
const data = notification.payload ? { ejson: EJSON.stringify(notification.payload) } : {};
data.title = notification.title;
data.message = notification.text;

@ -1,5 +1,4 @@
import { Meteor } from 'meteor/meteor';
import { EJSON } from 'meteor/ejson';
import { Match, check } from 'meteor/check';
import { Mongo } from 'meteor/mongo';
import { HTTP } from 'meteor/http';
@ -80,8 +79,6 @@ export class PushClass {
sendNotificationNative(app, notification, countApn, countGcm) {
logger.debug('send to token', app.token);
notification.payload = notification.payload ? { ejson: EJSON.stringify(notification.payload) } : {};
if (app.token.apn) {
countApn.push(app._id);
// Send to APN

Loading…
Cancel
Save