appfeel / node-pushnotifications

Push notifications for GCM, APNS, MPNS, AMZ (automatic detection from device token)
MIT License
534 stars 126 forks source link

APNs not working in production #61

Closed dozel closed 6 years ago

dozel commented 6 years ago

I'm using the apns key (.p8 file) and I thought it worked for both development and production environments. I'm also using GCM, and android pushes work just fine in both environments.

Would there be a reason why APNs would not work in production? Maybe I'm missing a step or two.

Any help would be greatly appreciated. Thanks!

dozel commented 6 years ago

image

I'm getting an empty error.

dozel commented 6 years ago

I just put "production: false" in the apn options and it worked in production as well. So why would I be running into this issue when production is true?

alex-friedl commented 6 years ago

Hi @dozel.

Can you share your entire configuration?

dozel commented 6 years ago

@alex-friedl sure!

const PushNotifications = require('node-pushnotifications');

const pushKey = './dir/to/AUTHKEY.p8';

const firebaseKey = 'FIREBASE_KEY';
const keyId = 'APPLE_KEY_ID';
const teamId = 'APPLE_TEAM_ID';
const topic = 'com.app.topic';

const settings = {
  gcm: {
    id: firebaseKey,
  },
  apn: {
    token: {
      key: pushKey,
      keyId,
      teamId,
    },
  },
};

const push = new PushNotifications(settings);

module.exports = {
  send(deviceIds, { title, body }, cb) {
    const data = {
      topic,
      title,
      body,
    };
    return push.send(deviceIds, data, cb);
  },
};
dozel commented 6 years ago

The issue was with my ios build. I had to re-create the push certificates and had to re-build. All is good now.