parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Version 2.1.4 Push notifications on Ubuntu

Open KudosGuy opened this issue 10 years ago • 8 comments

Hi,

I am on Ubuntu 14.04 with Parse server 2.1.4 and I am using pm2 with ecosystem.json file. Everything is running fine except push notifications.

Cloud Code - it worked when I used parse.com var queryPush = new Parse.Query(Parse.Installation); queryPush.equalTo("user_id", postAuthor.id); Parse.Push.send({ where: queryPush, data: { alert: 'Test....', badge: 1 } }, { success: function() { console.log('PUSH OK'); }, error: function(error) { console.log('#### PUSH ERROR'); }, useMasterKey: true });

And the output from pm2 logs command PUSH OK Can not find sender for push type ios, {"where":{"user_id":"6DoyIgHh5j"},"data":{"alert":"Test....","badge":1}} parse-wrapper-0 Can not find sender for push type android, {"where":{"user_id":"6DoyIgHh5j"},"data":{"alert":"Test....","badge":1}}

I narrowed it down that the parse-server doesnt know about the push configuration but I have tried put it in several places - to ecosystem with PARSE_SERVER_PUSH with many variations of quotes, to cli-definitions.js and to parse-server.js in /usr/lib/node_modules/parse-server/lib/cli/ and to index.js and so on...

  ios: [
  {
    pfx: '/home/parse/cert/dev_cert.p12',
    bundleId: 'ParseApp',
    production: false
  },
  {
    pfx: '/home/parse/cert/production_cert.p12',
    bundleId: 'ParseApp',  
    production: true
  }
  ]

Please dont send me to Wiki page about Push because I know what to do I just dont know where to put that configuration, I have never find a file that contains this line var server = new ParseServer in version 2.1.4.... Thank you

KudosGuy avatar Mar 08 '16 22:03 KudosGuy

I'm not sure about your current config, but in my index.js where I define the new ParseServer the push looks like this.

var api = new ParseServer({
  databaseURI: databaseUri || 'xxxxxx',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'xxxxx',
  masterKey: process.env.MASTER_KEY || 'xxxxx',
  restAPIKeY: process.env.RESTAPI_KEY || 'xxxxx',
  serverURL: process.env.SERVER_URL || 'https://xxxxx.herokuapp.com',  // Don't forget to change to https if needed
  fileKey: process.env.FILE_KEY || 'xxxxx',
  filesAdapter: new S3Adapter(
    process.env.AWS_ACCESS_KEY || 'xxxxx',
    process.env.AWS_SECRET_ACCESS_KEY || 'xxxxx',
    "xxxxx",
    {directAccess: true}
  ),
  push: {
      ios: {
        pfx: 'keys/xxxxx-apns.p12', // The filename of private key and certificate in PFX or PKCS12 format from disk  
        //cert: '', // If not using the .p12 format, the path to the certificate PEM to load from disk
        //key: '', // If not using the .p12 format, the path to the private key PEM to load from disk
        bundleId: 'com.xxxxx-dev', // The bundle identifier associate with your app
        production: false // Specifies which environment to connect to: Production (if true) or Sandbox
      }
    }
});

I dont see anything wrong with the lines you pasted but maybe my config might help out because I'm not sure where your config is set nor do I know what the full one looks like.

gateway avatar Mar 09 '16 03:03 gateway

Dude, I know how it looks like, this is the same from Wiki page, but my index.js looks like this http://paste.ofcode.org/iJhQd9nxuGhTuGFja35Mxf

KudosGuy avatar Mar 09 '16 09:03 KudosGuy

@KudosGuy people who say "Dude" do not get support :)

gateway avatar Mar 09 '16 17:03 gateway

@gateway your support is what I have seen many times and I wrote in the question that I know how I dont know where..., I just dont have this file in my Parse version 2.1.4 installed through npm, I searched the whole linux but no file contains the line var server = new ParseServer... anyway you are the only one here who cares so thanks anyway :-)

KudosGuy avatar Mar 09 '16 17:03 KudosGuy

yea sorry I couldnt really help, I looked at your config but its really hard to tell where things might be blowing up. I have 2.14 running and did some test pushes via curl without any issues

gateway avatar Mar 09 '16 17:03 gateway

@KudosGuy I suggest that you should be using parse-server-example as a base project instead of using parse-server directly. When I want to build a Parse Server app, I clone parse-server-example. It has the index.js where you initialize ParseServer and provide the push configuration details. https://github.com/ParsePlatform/parse-server-example/blob/master/index.js

https://github.com/ParsePlatform/parse-server-example

gfosco avatar Mar 09 '16 19:03 gfosco

@gfosco Ok, I will try that, but how is it possible that in my ecosystem file it ignores the "PARSE_SERVER_PUSH" but "PARSE_SERVER_CLOUD_CODE_MAIN": "/home/parse/cloud/main.js" works fine

KudosGuy avatar Mar 09 '16 20:03 KudosGuy

for ios, i can get it working with the following line, but i can't get the android version working. any ideas?

"PARSE_SERVER_PUSH": {"ios":{"pfx":"/home/parse/DevCertificates.p12","bundleId":"com.xxx.yyy","production":false}},

eplt avatar Jun 17 '16 15:06 eplt