Skip to content

Parse Server Push giving APNS 513 #697

Closed
@AlecKriebel

Description

@AlecKriebel

Hi all,

I'm getting an issue when trying to send push notifications over Parse Server using cloud code, specifically, the heroku server is spitting a 513 APNS at me. This was triggered by calling the cloud function on the iOS client-side.

I've discluded my keys and urls, etc, so they are in ALL_CAPS.

What do I need to do to make Push notification work on my parse server? Is there an issue with my .p12?

Here is my cloud function:

Parse.Cloud.define('test', function(req, res) {
    Parse.Push.send({
        channels: ['global'],
        data: {
            alert: 'Test',
            badge: 1,
            sound: 'default'
        }
    }, {
        success: function() {
            console.log('##### PUSH OK');
        },
        error: function(error) {
            console.log('##### PUSH ERROR' + error.message);
        },
        useMasterKey: true
    });
});

Here is my Index.js setup:

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI;

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

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 || 'APP_ID',
  masterKey: process.env.MASTER_KEY || 'MATER_KEY', //Add your master key here. Keep it secret!
  clientKey: 'CLIENT_KEY',
  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',
  push:{
    ios: {
            pdx: '/Users/AlecKriebel/Desktop/ParsePush.p12', // the path and filename to the .p12 file you exported earlier. 
            bundleId: 'BUNDLE-ID', 
            production: false
        }
  }
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a web site.');
});

var port = process.env.PORT || 1337;
app.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

Here is the server response:

2016-02-27T09:21:13.320224+00:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=POST path="/parse/functions/test" host=SERVER_URL request_id=e35a7606-e3e5-4303-a546-b6b604466f01 fwd="174.77.32.122" dyno=web.1 connect=1ms service=637ms status=503 bytes=0
2016-02-27T09:21:13.220879+00:00 app[web.1]: ##### PUSH OK
2016-02-27T09:21:13.322808+00:00 app[web.1]:         sound: 'default',
2016-02-27T09:21:13.322811+00:00 app[web.1]:         category: undefined } },
2016-02-27T09:21:13.322799+00:00 app[web.1]: APNS Notification caused error: 513 for device  Device {
2016-02-27T09:21:13.322803+00:00 app[web.1]:   token: <Buffer bf 90 0f e6 c5 85 85 cb 32 b8 d1 73 65 ce e8 61 3a 13 2d 98 be 3f 1d 50 14 68 a6 f9 c6 0d 68 95>,
2016-02-27T09:21:13.322804+00:00 app[web.1]:   connIndex: 0,
2016-02-27T09:21:13.322809+00:00 app[web.1]:         alert: 'Test',
2016-02-27T09:21:13.322810+00:00 app[web.1]:         'url-args': undefined,
2016-02-27T09:21:13.322806+00:00 app[web.1]:   appIdentifier: 'BUNDLE-ID' } { encoding: 'utf8',
2016-02-27T09:21:13.322806+00:00 app[web.1]:   payload: 
2016-02-27T09:21:13.322808+00:00 app[web.1]:       { badge: 1,
2016-02-27T09:21:13.322814+00:00 app[web.1]:   compiled: '{"aps":{"badge":1,"sound":"default","alert":"Test"}}',
2016-02-27T09:21:13.322807+00:00 app[web.1]:    { aps: 
2016-02-27T09:21:13.323511+00:00 app[web.1]: APNS can not find vaild connection for {"type":"Buffer","data":[191,144,15,230,197,133,133,203,50,184,209,115,101,206,232,97,58,19,45,152,190,63,29,80,20,104,166,249,198,13,104,149]}
2016-02-27T09:21:13.322812+00:00 app[web.1]:   expiry: undefined,
2016-02-27T09:21:13.322815+00:00 app[web.1]:   truncateAtWordEnd: false,
2016-02-27T09:21:13.322812+00:00 app[web.1]:   priority: 10,
2016-02-27T09:21:13.353632+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-02-27T09:21:13.354248+00:00 app[web.1]: npm ERR! npm  v3.6.0
2016-02-27T09:21:13.322813+00:00 app[web.1]:   retryLimit: -1,
2016-02-27T09:21:13.353835+00:00 app[web.1]: npm ERR! node v5.6.0
2016-02-27T09:21:13.322813+00:00 app[web.1]:   device: undefined,
2016-02-27T09:21:13.353332+00:00 app[web.1]: npm ERR! Linux 3.13.0-77-generic
2016-02-27T09:21:13.355041+00:00 app[web.1]: npm ERR! Exit status 1
2016-02-27T09:21:13.322817+00:00 app[web.1]:   _sound: 'default' }
2016-02-27T09:21:13.355376+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node index.js'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions