Meteor-Community-Packages / raix-push

DEPRECATED: Push notifications for cordova (ios, android) browser (Chrome, Safari, Firefox)
https://atmospherejs.com/raix/push
MIT License
514 stars 197 forks source link

Push.addListener does nothing. #319

Open thegizzada opened 6 years ago

thegizzada commented 6 years ago

The following code is written, however no response is received from any of the Push.addListener. Meteor.call('systemconsolelog') simply prints a message on the server console, as this is a production app I have not used alert() to avoid confusing users. However alert() does not do anything either. Has anyone had a similar issue?

I am trying to get the tokens to be reported and have followed the tutorial, but cannot get tokens to be received & stored.

`Meteor.startup(function () {

Push.Configure({ appName: 'Custom Name', android: { senderID: XXXXXXXXXXXXX, alert: true, badge: true, sound: true, vibrate: true, clearNotifications: false, icon: 'pushicon', iconColor: '#edd759' }, ios: { alert: true, badge: true, sound: true } });

// Internal events Push.addListener('token', function(token) { var message = 'token: ' + JSON.stringify(token); Meteor.call('systemconsolelog',message); });

Push.addListener('error', function(err) { var message = 'error: ' + JSON.stringify(err); Meteor.call('systemconsolelog',message); });

Push.addListener('register', function(evt) { // Platform specific event - not really used var message = 'register: ' + JSON.stringify(evt); Meteor.call('systemconsolelog',message); });

Push.addListener('alert', function(notification) { // Called when message got a message in forground var message = 'alert: ' + JSON.stringify(notification); Meteor.call('systemconsolelog',message); });

Push.addListener('sound', function(notification) { // Called when message got a sound var message = 'sound: ' + JSON.stringify(notification); Meteor.call('systemconsolelog',message); });

Push.addListener('badge', function(notification) { // Called when message got a badge var message = 'badge: ' + JSON.stringify(notification); Meteor.call('systemconsolelog',message); });

Push.addListener('startup', function(notification) { // Called when message recieved on startup (cold+warm) var message = 'startup: ' + JSON.stringify(notification); Meteor.call('systemconsolelog',message); });

Push.addListener('message', function(notification) { // Called on every message var message = 'message: ' + JSON.stringify(notification); Meteor.call('systemconsolelog',message); });

Meteor.call('systemconsolelog','tried everything.');

});`

raix commented 6 years ago

That sounds like a bug - but not 100% why - internally in the code I rely on Push.on - but it should be the same (using an event emitter https://github.com/raix/push/blob/master/lib/common/main.js#L2)