parse-community / parse-server-push-adapter

A push notification adapter for Parse Server
https://parseplatform.org
MIT License
88 stars 100 forks source link

Push is not delivered to iOS device #8

Closed yaalaa closed 8 years ago

yaalaa commented 8 years ago

I've got Parse-hosted app with push notifications working good with iOS. Now I'm trying to migrate to Heroku+mLab. Currently I cannot get push notifications work. Here's adapter logs I see:

verb parse-server-push-adapter APNS APNS Connection 0 Connected
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to <mydevicetoken>
ERR! parse-server-push-adapter APNS cannot find vaild connection for <mydevicetoken>
verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
verb parse-server-push-adapter APNS APNS Connection 0 Connected

Honorable @flovilmart just said it's not a problem of parse-server-push adapter (https://github.com/parse-server-modules/parse-server-push-adapter/issues/4#issuecomment-203570449). Maybe it's true. I'm not sure it is, sorry. The logs are from adapter, i.e. this project. Just requesting your help.

There's no error log from npm apn lib which adapter seems to use for communicating with APN. There are just logs from adapter and those logs are confusing me a bit. First it says transmitted then complains about no valid connection.

Is there any idea on how to get more details from adapter & npm apn?

okaris commented 8 years ago

@yaalaa can you share your configuration in index.js?

yaalaa commented 8 years ago

Here you are:

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || '<my app id>',
  masterKey: process.env.MASTER_KEY || '<my master key>', //Add your master key here. Keep it secret!
  clientKey: process.env.CLIENT_KEY || '<my client key>',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
  push: {
    ios: [
      {
        pfx: __dirname + '/<my pfx push file>',
        bundleId: '<my app bundle ID>',
        production: true, 
      },
    ],
  },
  liveQuery: {
    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  }
});
okaris commented 8 years ago

Make sure you are not trying to use your Development Push Certificate for production. Make sure that your bundleId is what it is in developer.apple.com

in my case my bundle id was _..Coralline but i put in *._***.coralline make sure you have the latest version of parse server which is 2.2.4 at the moment.

flovilmart commented 8 years ago

Make sure that you device token were acquired with a production app otherwise that would be the perfect case for your problem, try adding a dev pfx, marking production: false

yaalaa commented 8 years ago

It seems you're quite right dude. Adding debug pfx apparently solves the issue.

yaalaa commented 8 years ago

It would be nice to have a field in Installation to indicate device token APN production/development (if it's possible). :)

flovilmart commented 8 years ago

That's the original parse.com behaviour, that's why we have those logs for invalid connections...