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

APN Feedback Service not working #331

Open KirbySSmith opened 6 years ago

KirbySSmith commented 6 years ago

Affected Version: 3.3.0

The configuration of the Feedback Service does not work with documented raix config. certData and keyData are nested under options.apn.certData and options.apn.keyData. https://github.com/raix/push/blob/v3.3.0/lib/server/push.api.js#L242

            var feedbackOptions = {
                'batchFeedback': true,

                // Time in SECONDS
                'interval': 5,
                production: !options.apn.development,
                cert: options.certData,
                key: options.keyData,
                passphrase: options.passphrase
            };

            var feedback = new apn.Feedback(feedbackOptions);

So it should be:

            var feedbackOptions = {
                'batchFeedback': true,

                // Time in SECONDS
                'interval': 5,
                production: !options.apn.development,
                cert: options.apn.certData,
                key: options.apn.keyData,
                passphrase: options.passphrase
            };

            var feedback = new apn.Feedback(feedbackOptions);

Making this change fixes the configuration. However, once configured properly an additional downstream error is thrown. The on 'feedback' callback function is not bound to the meteor environment.

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

https://github.com/raix/push/blob/v3.3.0/lib/server/push.api.js#L254

            feedback.on('feedback', function (devices) {
                devices.forEach(function (item) {
                    // Do something with item.device and item.time;
                    // console.log('A:PUSH FEEDBACK ' + item.device + ' - ' + item.time);
                    // The app is most likely removed from the device, we should
                    // remove the token
                    _removeToken({
                        apn: item.device
                    });
                });
            });