Giter Site home page Giter Site logo

parse-community / parse-server-push-adapter Goto Github PK

View Code? Open in Web Editor NEW
85.0 14.0 100.0 986 KB

A push notification adapter for Parse Server

Home Page: https://parseplatform.org

License: MIT License

JavaScript 98.29% Handlebars 1.71%
parse-server hacktoberfest

parse-server-push-adapter's Introduction

Parse Server Push Adapter

Build Status Snyk Badge Coverage auto-release

Node Version

npm latest version


The official Push Notification adapter for Parse Server. See Parse Server Push Configuration for more details.


Installation

npm install --save @parse/push-adapter@<VERSION>

Replace <VERSION> with the version you want to install.

Configure Parse Server

import { ParsePushAdapter } from '@parse/push-adapter';

// For CommonJS replace the import statemtent above with the following line:
// const ParsePushAdapter = require('@parse/push-adapter').default;

const parseServerOptions = {
  push: {
    adapter: new ParsePushAdapter({
      ios: {
        // Apple push options
      },
      android: {
        // Android push options
      },
      web: {
        // Web push options
      },
      expo: {
        // Expo push options
      }
    })
  }
  // Other Parse Server options
};

Apple Push Options

Parse Server Push Adapter currently supports these types of Apple ecosystems:

  • ios: iPhone, iPad, and iPod touch apps
  • osx: macOS, and macCatalyst apps
  • tvos: tvOS apps

Delivering push notifications to Apple devices can be done either via Apple Push Notification Service (APNS), or via Firebase Cloud Messaging (FMC). Note that each category of Apple devices require their own configuration section:

  • APNS requires a private key that can be downloaded from the Apple Developer Center at https://developer.apple.com/account under Certificates > Identifiers & Profiles. The adapter options also require the app ID and team ID which can be found there.
  • FCM requires a private key that can be downloaded from the Firebase Console at https://console.firebase.google.com in your project under Settings > Cloud Messaging.

Example options:

Both services (APNS, FCM) can be used in combination for different Apple ecosystems.

ios: {
  // Deliver push notifications to iOS devices via APNS
  token: {
    key: __dirname + '/apns.p8',
    keyId: '<APNS_KEY_ID>',
    teamId: '<APNS_TEAM_ID>'
  },
  topic: '<BUNDLE_IDENTIFIER>',
  production: true
},
osx: {
  // Deliver push notifications to macOS devices via FCM
  firebaseServiceAccount: __dirname + '/firebase.json'
}

Android Push Options

Delivering push notifications to Android devices can be done via Firebase Cloud Messaging (FCM):

Example options:

android: {
  firebaseServiceAccount: __dirname + '/firebase.json'
}

Google Cloud Service Account Key

The Firebase console allows to easily create and download a Google Cloud service account key JSON file with the required permissions. Instead of setting firebaseServiceAccount to the path of the JSON file, you can provide an object representing a Google Cloud service account key:

android: {
  firebaseServiceAccount: {
    projectId: '<PROJECT_ID>',
    clientEmail: 'example@<PROJECT_ID>.iam.gserviceaccount.com',
    privateKey: '-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n'
  }
}

This can be helpful if you are already managing credentials to Google Cloud APIs in other parts of your code and you want to reuse these credentials, or if you want to manage credentials on a more granular level directly in Google Cloud. Make sure that the service account has the permission cloudmessaging.messages.create which is for example part of role Firebase Cloud Messaging API Admin.

Migration to FCM HTTP v1 API (June 2024)

⚠️ Sending push notifications to Android devices via the FCM legacy API was deprecated on June 20 2023 and was announced to be decommissioned in June 2024. See Google docs. To send push notifications to the newer FCM HTTP v1 API you need to update your existing push configuration for Android by replacing the key apiKey with firebaseServiceAccount.

Example options (deprecated):

android: {
  // Deliver push notifications via FCM legacy API (deprecated)
  apiKey: '<API_KEY>'
}

Expo Push Options

Example options:

expo: {
  accessToken: '<EXPO_ACCESS_TOKEN>'
}

For more information see the Expo docs.

Bundled with Parse Server

Parse Server already comes bundled with a specific version of the push adapter. This installation is only necessary when customizing the push adapter version that should be used by Parse Server. When using a customized version of the push adapter, ensure that it's compatible with the version of Parse Server you are using.

When using the bundled version, it is not necessary to initialize the push adapter in code and the push options are configured directly in the push key, without the nested adapter key:

const parseServerOptions = {
  push: {
    ios: {
      // Apple push options
    }
    // Other push options
  }
  // Other Parse Server options
};

Logging

You can enable verbose logging to produce a more detailed output for all push sending attempts with the following environment variables:

VERBOSE=1

or

VERBOSE_PARSE_SERVER_PUSH_ADAPTER=1

parse-server-push-adapter's People

Contributors

0x18b2ee avatar acinader avatar alexanderedge avatar amnell avatar bnham avatar davimacedo avatar dependabot[bot] avatar douglasmuraoka avatar dplewis avatar flovilmart avatar funkenstrahlen avatar greenkeeper[bot] avatar jeffjen avatar jimnor0xf avatar leonluc-dev avatar mman avatar mmazzarolo avatar mortenmo avatar mtrezza avatar natanrolnik avatar parseplatformorg avatar polo2244 avatar rogerhu avatar semantic-release-bot avatar simonegiacco avatar snyk-bot avatar supermar1010 avatar technowise avatar tingham avatar tomwfox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

parse-server-push-adapter's Issues

Support Apple's APNS Token Authentication

(Issue originally opened by @EricNetsch in parse-community/parse-server#3315)

I would like to start using Apple's new push notification authentication protocol instead of using traditional certs. Is this possible with parse-server yet? This would be a fantastic addition to the platform to simplify push certificate management.

Provider Authentication Tokens

To securely connect to APNs, you can use provider authentication tokens or provider certificates. This section describes connections using tokens.

The provider API supports the JSON Web Token (JWT) specification, letting you pass statements and metadata, called claims, to APNs, along with each push notification. For details, refer to the specification at https://tools.ietf.org/html/rfc7519. For additional information about JWT, along with a list of available libraries for generating signed JWTs, see https://jwt.io

A provider authentication token is a JSON object that you construct, whose header must include:

The encryption algorithm (alg) you use to encrypt the token
A 10-character key identifier (kid) key, obtained from your developer account
The claims payload of the token must include:

The issuer (iss) registered claim key, whose value is your 10-character Team ID, obtained from your developer account
The issued at (iat) registered claim key, whose value indicates the time at which the token was generated, in terms of the number of seconds since Epoch, in UTC
After you create the token, you must sign it with a private key. You must then encrypt the token using the Elliptic Curve Digital Signature Algorithm (ECDSA) with the P-256 curve and the SHA-256 hash algorithm. Specify the value ES256 in the algorithm header key (alg). For information on how to configure your token, search Xcode help for the phrase “Configure push notifications.”

A decoded JWT provider authentication token for APNs has the following format:

{
"alg": "ES256",
"kid": "ABC123DEFG"
}
{
"iss": "DEF123GHIJ",
"iat": 1437179036
}
NOTE

APNs supports only provider authentication tokens that are signed with the ES256 algorithm. Unsecured JWTs, or JWTs signed with other algorithms, are rejected, and your provider server receives the InvalidProviderToken (403) response.

To ensure security, APNs requires new tokens to be generated periodically. A new token has an updated issued at claim key, whose value indicates the time the token was generated. If the timestamp for token issue is not within the last hour, APNs rejects subsequent push messages, returning an ExpiredProviderToken (403) error.

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html

Please advise on any existing solutions/ implementations.

Sent and deliver always 0

parse-server: 2.3.7
parse dashboard: 1.0.25
If I sent an push notification with parse dashboard or rest api the sent and deliver number is always 0. The push notifications always received and displayed on iOS device.

2017-04-25T20:15:04.409579+00:00 app[web.1]: verbose: REQUEST for [POST] /parse/push: {
2017-04-25T20:15:04.409587+00:00 app[web.1]: "where": {},
2017-04-25T20:15:04.409588+00:00 app[web.1]: "data": {
2017-04-25T20:15:04.409589+00:00 app[web.1]: "alert": "Test 1"
2017-04-25T20:15:04.409590+00:00 app[web.1]: }
2017-04-25T20:15:04.409592+00:00 app[web.1]: } method=POST, url=/parse/push, host=whispering-spire-56438.herokuapp.com, connection=close, origin=https://parse-playground-dashboard.herokuapp.com, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36, content-type=text/plain, accept=/, referer=https://parse-playground-dashboard.herokuapp.com/apps/ParsePlayground/push/new, accept-encoding=gzip, deflate, br, accept-language=de,en;q=0.8, x-request-id=ce50e75d-1369-4316-a5ec-7f0bf3e10852, x-forwarded-for=188.103.184.163, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=0, x-request-start=1493151304405, total-route-time=0, content-length=203, , alert=Test 1
2017-04-25T20:15:04.416818+00:00 app[web.1]: verbose: RESPONSE from [POST] /parse/push: {
2017-04-25T20:15:04.416820+00:00 app[web.1]: "headers": {
2017-04-25T20:15:04.416822+00:00 app[web.1]: "X-Parse-Push-Status-Id": "CUW9Lq7jRd"
2017-04-25T20:15:04.416822+00:00 app[web.1]: },
2017-04-25T20:15:04.416823+00:00 app[web.1]: "response": {
2017-04-25T20:15:04.416823+00:00 app[web.1]: "result": true
2017-04-25T20:15:04.416823+00:00 app[web.1]: }
2017-04-25T20:15:04.416824+00:00 app[web.1]: } X-Parse-Push-Status-Id=CUW9Lq7jRd, result=true
2017-04-25T20:15:04.423496+00:00 app[web.1]: verbose: _PushStatus CUW9Lq7jRd: sending push to 1 installations
2017-04-25T20:15:04.432339+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to 3a1c76787c06397ff726a0464a7e34a5971e5eb1a4d5dec8eaffaa7c98822a3e
2017-04-25T20:15:04.432663+00:00 app[web.1]: verbose: _PushStatus CUW9Lq7jRd: sent push! 0 success, 0 failures
2017-04-25T20:15:04.447282+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 1 Notification transmitted to 3a1c76787c06397ff726a0464a7e34a5971e5eb1a4d5dec8eaffaa7c98822a3e
2017-04-25T20:15:04.449121+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Disconnected
2017-04-25T20:15:04.738997+00:00 app[web.1]: verb parse-server-push-adapter APNS APNS Connection 0 Connected

Status 400 and reason BadDeviceToken

I've updated the parse-server to the latest 2.5.3 version and parse-server-push-adapter v 2.0.0 and now my error logs are full of these messages:

3|parse-wr | node-pre-gyp
3|parse-wr |  
3|parse-wr | ERR!
3|parse-wr |  
3|parse-wr | parse-server-push-adapter APNS
3|parse-wr |  APNS error transmitting to device 28c89bdc6a0e7a6454fb0cc446229a0841eecdea955533d3c549a658bb15fc98 with status 400 and reason BadDeviceToken

There are so many of them that I can't see anything else.

The questions are:

  1. How can I ignore these errors in my pm2 config file?
  2. Is there a way to remove bad device tokens automatically from Installation Collection?

ERR! parse-server-push-adapter GCM send errored: 401

untitledguthub

My Server was Working Fine but From some days the notification was not recieved to my devices so i check whole github and stackoverflow and was unablw to find any solution so if anybody knows how to fix this

apns never reports numFailed in _PushStatus.

GCM works fine in this regard, and properly reports success/failures, but apns never updates the tracker on fail.
log:

verbose: sending push to 1 installations
  apn Socket drained 1 +4s
  apn 0 left to send +0ms
verbose: sent push! 1 success, 0 failures
  apn 0 left to send +5ms
  apn Notification 0 caused an error: 5 +275ms
ERR! parse-server-push-adapter APNS cannot find vaild connection for xxxxxxxx
  apn Raising error: 5 { encoding: 'utf8',
  payload: 

corresponding _PushStatus ("numFailed" : 0)

{ "_id" : "V4J5VKGvQf", "pushTime" : "2017-02-08T00:38:25.616Z",
 "query" : "{\"objectId\":\"8BHXqhukp5\"}", 
"payload" : "{\"alert\":\"just a test\"}", 
"source" : "rest", "status" : "succeeded", "numSent" : 1, 
"pushHash" : "cddc3a1fd8d20707a0ff8b839a60737a",
 "_wperm" : [ ], "_rperm" : [ ],
 "_acl" : {  }, "_created_at" : ISODate("2017-02-08T00:38:25.616Z"), 
"_updated_at" : ISODate("2017-02-08T00:38:28.645Z"),
 "numFailed" : 0, "sentPerType" : { "ios" : 1 } }

Android device still receives push from old installationId after app re-installed

I'm seeing the same issue that @jiawenzhang had in parse-community/parse-server#1705

Here is the issue:

  • Install app on Android phone, open app and register with parse-server (as user A), get installationId_1
  • Uninstall app and re-install app on the same phone, open app and register with parse-server (as user B), get installationId_2.

Note that the app on this phone is now associated with installationId_2 (as user B). The installationId_1 should not be valid.

  • Now send a push notification to the parse-server targeting installationId_1, the app still receives the push even when its installationId is not installationId_1.

The parse-server is showing the following in the log:

verb parse-server-push-adapter GCM sending to 1 devices
verb parse-server-push-adapter GCM GCM Response: {
verb parse-server-push-adapter GCM "multicast_id": 7047466558839750000,
verb parse-server-push-adapter GCM "success": 1,
verb parse-server-push-adapter GCM "failure": 0,
verb parse-server-push-adapter GCM "canonical_ids": 1,
verb parse-server-push-adapter GCM "results": [
verb parse-server-push-adapter GCM {
verb parse-server-push-adapter GCM "registration_id": "APA91bEB01Bmhz3g0ZMRqBJIwg-DbQzNnvYeZxJKoj0ixVYFBW9UN2zQIMiDV86FWDDqHlJInaA9h_Mb-xV3tfCUNk2mpUdAjeYi7AdM6ggImQbATHKEp24Xg7yyS76nNLH1UDXqiMxP",
verb parse-server-push-adapter GCM "message_id": "0:1475256512754990%d7f644cef9fd7ecd"
verb parse-server-push-adapter GCM }
verb parse-server-push-adapter GCM ]
verb parse-server-push-adapter GCM }

According to GCM, the app-server (parse-server) should be updated to use the registration_id that was returned:
https://developers.google.com/cloud-messaging/registration#how-uninstalled-client-app-unregistration-works

The problem is I don't want any notifications to be successfully sent with the installationId_1.

If I try to duplicate this same issue with the production api.parse.com and SDK, I can't duplicate it.

NOTE: GCM states "Eventually, the registration token (installationId_1) will be removed and the server will get a NotRegistered error" - Does anyone know how long this would take?

Push notifications not sent

Environment Setup

Nothing special


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

var app = express();

// Specify the connection string for your mongodb database
// and the location to your Parse cloud code
var api = new ParseServer({
  databaseURI: 'mongodb://localhost:27017/app',
  appId: 'APP_NAME',
  masterKey: 'MASTER_KEY',
  cloud: __dirname + '/cloud/main.js',
  serverURL: 'http://localhost:1337/parse', // Don't forget to change to https if needed
    push: {
      android: {
        senderId: 'SENDER_ID',
        apiKey: 'API_KEY'
      }
    }
});

// Serve the Parse API on the /parse URL prefix
app.use('/parse', api);

// Hello world
app.get('/', function(req, res) {
  res.status(200).send('Express is running here.');
});

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

Steps to reproduce

Using Parse Android SDK 1.13.0 and parse-server version 2.2.2

Logs/Trace

Parse Server Verbose trace:


POST /parse/push { 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.1 (NodeJS 5.8.0)',
  accept: '*/*',
  'content-type': 'text/plain',
  host: 'localhost:1337',
  'content-length': '311',
  connection: 'close' } {
  "channels": [
    "SOME_CHANNEL"
  ],
  "data": {
    "title": "dummy title",
    "message": "dummy message",
    "action": "ACTION",
    "senderId": "4zSfKw2T5b"
  }
}
response: {
  "response": {
    "result": true
  }
}
response: {
  "response": {
    "result": "sent"
  }
}

DB Record
{ "_id" : ObjectId("56f45b891eb3cdae4d74d160"), "objectId" : "WWfLEatYht", "pushTime" : "2016-03-24T21:26:33.921Z", "_created_at" : ISODate("2016-03-24T21:26:33.921Z"), "query" : "{\"channels\":{\"$in\":[\"SOME_CHANNEL\"]}}", "payload" : { "title" : "dummy title", "message" : "dummy message", "action" : "ACTION", "senderId" : "4zSfKw2T5b"}, "source" : "rest", "title" : null, "expiry" : null, "status" : **"succeeded", "numSent" : 0**, "pushHash" : "d1eeaba5cb95ce819c32efe295b2fe96", "_wperm" : [ ], "_rperm" : [ ], **"numFailed" : 0**}
Can't find anything in server logs even when VERBOSE is set to 1, where can I find GCM request and response?

Possible duplicate #1127

APNS VError: apn write failed: Not receiving Ping response after 150000 ms

I run parse server 2.5.3 with push adapter 2.0.0.

After a lot of errors in the console APNS error transmitting to device XXXXXXXXXXXXXX with status 400 and reason BadDeviceToken I see APNS connection failing.

Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS VError: apn write failed: Not receiving Ping response after 150000 ms 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at Stream.stream.on.err (/app/node_modules/apn/lib/client.js:105:21) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at emitOne (events.js:115:13) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at Stream.emit (events.js:210:7) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at _connection._streamIds.forEach (/app/node_modules/apn/lib/protocol/endpoint.js:155:16) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at Array.forEach (native) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at Endpoint.close [as _close] (/app/node_modules/apn/lib/protocol/endpoint.js:139:33) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at emitOne (events.js:120:20) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at TLSSocket.emit (events.js:210:7) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at _handle.close (net.js:549:12) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS     at TCP.done [as _onclose] (_tls_wrap.js:350:7) 
Jul 20 11:03:31 parse-server app/web.1: node-pre-gyp ERR! parse-server-push-adapter APNS  APNS error transmitting to device %s with error %s

This causes push notifications to not be delivered.

ERR! parse-server-push-adapter APNS cannot find vaild connection

Getting this error "ERR! parse-server-push-adapter APNS cannot find vaild connection", while sending message from one application to another application.

Following is my index.js file of parse server,

// Example express application adding the parse-server module to expose Parse
// compatible API routes.

const resolve = require('path').resolve;

var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var path = require('path');
var SimpleMailgunAdapter = require('/var/WWW/Parse/node_modules/parse-server-simple-mailgun-adapter');
var FpPushAdapter = require('/var/WWW/Parse/node_modules/parse-server-fp-push-adapter');
var path = require('path');
var pushConfig = {
ios: [ //like official parse-server-push-plugin (already array compatible), e.g.:
{
pfx: '/var/WWW/Parse/files/nct_apns-dev-cert.p12', // Prod PFX or P12
// pfx: path.join(__dirname, "/files/Nector_apns-dev-cert.p12"),
// passphrase: '', // optional password to your p12
bundleId: 'com.otl.nct',
// cert: '/var/WWW/Parse/files/Nector_apns-dev.pem', // If not using the .p12 format, the path to the certificate PEM to load from disk
production: true // Prod
},
{
pfx: '/var/WWW/Parse/files/nectorpro-apns-dev-cert.p12', // Dev PFX or P12
// pfx: path.join(__dirname, "/files/nectorpro-apns-dev-cert.p12"),
// passphrase: '', // optional password to your p12
bundleId: 'com.otl.nctpro',
// cert: '/var/WWW/Parse/files/nctpro-apns-dev.pem', // If not using the .p12 format, the path to the certificate PEM to load from disk
production: true // Dev
}
]
};

var fpPushAdapter = new FpPushAdapter(pushConfig);

var databaseUri = "";

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 || '/var/WWW/Parse/cloud/main.js',
appId: process.env.APP_ID || '',
masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
},
//Push Notification
push: {
adapter: fpPushAdapter
}
});

// 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 static assets from the /public folder
app.use('/public', express.static(path.join(__dirname, '/public')));

// 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 website. Please star the parse-server repo on GitHub!');
});

// There will be a test page available on the /test path of your server url
// Remove this before launching your app
app.get('/test', function(req, res) {
res.sendFile(path.join(__dirname, '/public/test.html'));
});

var port = process.env.PORT || 1337;
var httpServer = require('http').createServer(app);

httpServer.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.');
});

// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);

push notification not delivered via parse

Hi. I was able make to make push notification is working. I tested it on REST.

POST
Host: android.googleapis.com/gcm/send
Content-Type: application/json
Authorization: key=**apiKey**
Cache-Control: no-cache
Postman-Token: b33c61dc-a779-9198-bd96-aaf6c24fac6c

{
  "data": {
      "message": "hello world"
  },
  "registration_ids" : ["**deviceToken**"]
}

and my device got notification. Now I'm struggling to make parse push working.

POST localhost:7002/server/push
X-Parse-Application-Id: SSShop
X-Parse-Master-Key: 123
Content-Type: application/json

{
  "where": {},
  "data": {
      "alert": "hello world 123"
  }
}

the output: { result: true }, but notification is not received on device. Trying send push notification via Parse Dashboard and got output like this:

verbose: sending push to 2 installations
verbose: sent push! 0 success, 0 failures.

server.js:

...
const instance = {
  appId:            'SSShop',
  port:             7002,
  serverURL:        'http://localhost:7002/server',
  masterKey:        '123',
  databaseURI:      'mongodb://docker/ssshop',
  publicServerURL:  'http://localhost:7002/server',
  mountPath:        '/server',
  verifyUserEmails: true,
  appName:          'SSShop',
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      fromAddress: 'XX',
      domain:      'XX',
      apiKey:      'XX'
    }
  },
  push: {
    android: {
      senderId: "92014XXXXX",
      apiKey: "**apiKey**"
    }
  }
}
...

package.json:

    "parse": "~1.8.5",
    "parse-dashboard": "~1.0.13",
    "parse-server": "~2.2.11",

checking node_modules and got parse-server-push-adapter use version 1.0.4.

ERR! parse-server-push-adapter APNS cannot find vaild connection

My parse server log is filled with ERR! parse-server-push-adapter APNS cannot find vaild connection errors. Push Notifications reach devices though. This seems to happen for devices that uninstalled the app and are now no longer reachable.

Some discussion can be found here as this issue got moved and reopened here: parse-community/parse-server#1665 (comment)

Environment Setup

    push: {
        android: { senderId: '...', apiKey: '...' }, // setting android keys empty to remove error
        ios: {
          pfx: __dirname + process.env.APN_PUSH_P12_PATH, // The filename of private key and certificate in PFX or PKCS12 format from disk  
          bundleId: process.env.APN_BUNDLE_ID, // The bundle identifier associate with your app
          production: false // Specifies which environment to connect to: Production
        }
    }

Steps to reproduce

  • Install app on device. Does register to parse server.
  • Uninstall app
  • send push notification

Expected Behaviour

Devices that are no longer reachable get removed from the database.

The make it clear: Push notification do get send out fine to valid devices. I just do not know why this error appears. I think the error is caused by devices which do not have the app installed any more?

Logs/Trace

Apr 19 20:36:36 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 19 20:36:36 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 19 20:36:37 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 19 21:42:54 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 19 21:42:55 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 19 21:42:55 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 20 19:29:50 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 20 19:29:51 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 20 19:29:52 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 20 23:56:00 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 20 23:56:01 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 20 23:56:02 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 21 20:30:10 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 21 20:30:11 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 21 20:30:12 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 21 22:30:59 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 21 22:31:00 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 21 22:31:01 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 22 16:17:58 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 22 16:17:58 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 22 16:17:59 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 22 16:33:06 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 22 16:33:07 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 22 16:33:07 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 22 16:34:49 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 22 16:34:50 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 22 16:34:51 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 22 17:10:04 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 22 17:10:04 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 22 17:10:05 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 24 10:47:19 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 24 10:47:19 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 24 10:47:20 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 24 11:02:55 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 24 11:02:56 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 24 11:02:57 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 24 11:25:33 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 24 11:25:34 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 24 11:25:34 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7
Apr 24 11:38:18 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 03750761765ab097c58b1f90d30a078d892
Apr 24 11:38:18 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 37bc6500dd5e33ff43dc7a3f1e45ebc25a5
Apr 24 11:38:19 xsn-app parse-app-production[6721]: ERR! parse-server-push-adapter APNS cannot find vaild connection for 899efce347b266412d39da18379569bdaa7

Parse Push to iOS hanging in parse-server 2.5.3

In reference to parse-community/parse-server#4015

Parse.Cloud.define('sendPushToUsers', (req, resp) => {
  const pushQuery = new Parse.Query(Parse.Installation);
  const user = new Parse.Object('_User');
  user.id = 'YXLPLWXJ71';
  pushQuery.equalTo('user', user);
  Parse.Push.send({
    where: pushQuery,
    data: {
      alert: 'Hello Squad',
      title: "GreatApp"
    }
  }, { useMasterKey: true })
    .then(() => resp.success('Push was sent successfully.'))
    .catch((error) => { resp.error(`Push failed: ${error.message}`); });
});
info: Ran cloud function sendPushToUsers for user undefined with:
  Input: {"name":"value"}
  Result: "Push was sent successfully." functionName=sendPushToUsers, name=value, user=undefined
(node:42607) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 
TypeError: notification.setAlertTitle is not a function

APNS bundleId is deprecated, use topic instead

With the new release I saw this in my logs: APNS bundleId is deprecated, use topic instead. However I could not find anything about how to use topic in my configuration in the docs yet. I would love to see this covered as I will probably not be the only one with this issue.

Parse Server Crash on invalid/expired APNS cert

I would like to reference an issue from parse-community/parse-server#3575 which crashes the node process when APNS cert is expired. It also happens for me, here is the stack trace:

3|parse-se | Error: certificate has expired: 2016-09-27T04:03:38.000Z
3|parse-se |     at validateCredentials (/opt/parse-server-tc/node_modules/apn/lib/credentials/validate.js:12:9)
3|parse-se |     at /opt/parse-server-tc/node_modules/apn/lib/connection.js:163:5
3|parse-se |     at _fulfilled (/opt/parse-server-tc/node_modules/q/q.js:834:54)
3|parse-se |     at self.promiseDispatch.done (/opt/parse-server-tc/node_modules/q/q.js:863:30)
3|parse-se |     at Promise.promise.promiseDispatch (/opt/parse-server-tc/node_modules/q/q.js:796:13)
3|parse-se |     at /opt/parse-server-tc/node_modules/q/q.js:604:44
3|parse-se |     at runSingle (/opt/parse-server-tc/node_modules/q/q.js:137:13)
3|parse-se |     at flush (/opt/parse-server-tc/node_modules/q/q.js:125:13)
3|parse-se |     at _combinedTickCallback (internal/process/next_tick.js:67:7)
3|parse-se |     at process._tickDomainCallback [as _tickCallback] (internal/process/next_tick.js:122:9)

parse-server-push-adapter version: 1.2.0

APNS TypeError: Cannot read property 'key' of undefined

When trying to send a notification through APNS, I get the following crash:

verbose: sending push to 1 installations
  apn Initialising connection +0ms
  apn Loading Credentials +23ms
  apn 1 left to send +8ms
  apn Module initialisation error: +122ms [TypeError: Cannot read property 'key' of undefined]
  apn Raising error: +0ms 513 { encoding: 'utf8',
  payload: 
   { action: 'redacted',
     type: 'chat',
     message: 'Test message 18:38:29',
     payload: 
      { id: 1,
        body: 'Test message 18:38:29',
        sent_by: 'Joses-MacBook-Pro.local',
        source: 'web',
        sent_at: '2016-06-23 18:38:29' },
     aps: 
      { badge: undefined,
        sound: undefined,
        alert: undefined,
        'content-available': 1,
        'url-args': undefined,
        category: undefined } },
  expiry: undefined,
  priority: 10,
  retryLimit: -1,
  device: undefined,
  compiled: '{"action":"me.beelink.beetrack2.PUSH_NOTIFICATION","type":"chat","message":"Test message 18:38:29","payload":{"id":1,"body":"Test message 18:38:29","sent_by":"Joses-MacBook-Pro.local","source":"web","sent_at":"2016-06-23 18:38:29"},"aps":{"content-available":1}}',
  truncateAtWordEnd: false,
  _contentAvailable: 1 } Device {
  token: <Buffer redacted>,
  connIndex: 0,
  appIdentifier: 'redacted',
  callback: [Function] }
  apn Initialising connection +3ms
  apn Loading Credentials +0ms
  apn 1 left to send +1ms
/Users/jlh/dev/web/parse_server/node_modules/parse-server/lib/ParseServer.js:351
            throw err;
            ^

TypeError: Cannot read property 'key' of undefined
    at validateCredentials (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/credentials/validate.js:6:51)
    at /Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:163:5
    at _fulfilled (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:796:13)
    at /Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:604:44
    at runSingle (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:137:13)
    at flush (/Users/jlh/dev/web/parse_server/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:125:13)
    at doNTCallback0 (node.js:407:9)
    at process._tickDomainCallback (node.js:377:13)

Here's the gist of our config:

var api = new ParseServer({
  databaseURI: e.DATABASE_URI,
  appId: e.APP_ID,
  masterKey: e.MASTER_KEY,
  serverURL: e.SERVER_URL,
  verbose: true,
  push: {
    android: {
      senderId: e.ANDROID_SENDER_ID,
      apiKey: e.ANDROID_API_KEY
    },
    ios: [
      {
        pfx: __dirname + '/config/' + e.IOS_PFX_DEV,
        bundleId: e.IOS_BUNDLE_ID_DEV,
        production: false
      },
      {
        pfx: __dirname + '/config/' + e.IOS_PFX_PRO,
        bundleId: e.IOS_BUNDLE_ID_PRO,
        production: true
      }
    ]
  }
});

And the request I'm testing with:

curl \
  -vvv \
    --connect-timeout 4 \
  -X POST \
  -H "X-Parse-Master-Key: $MASTER_KEY" \
  -H "X-Parse-Application-Id: $APPLICATION_ID" \
  -H "Content-Type: application/json" \
  -d "{
        \"channels\": [
          \"$CHANNEL\"
        ],
        \"data\": {
          \"action\": \"me.beelink.beetrack2.PUSH_NOTIFICATION\",
          \"type\": \"chat\",
          \"message\": \"$MESSAGE\",
          \"payload\": $PAYLOAD,
                    \"content-available\": 1
        }
      }" \
    --url "$URL"

The project can be found here: https://github.com/Beetrack/parse_server

I'm really clueless on what I might be doing wrong, any help is greatly appreciated.

APNS bundleId is deprecated, use topic instead

Hello

I have a problem your plugin, Before that everything ok but when I reinstall package via command line npm install. I have get a error

 0|parse-se | node-pre-gyp WARN parse-server-push-adapter APNS bundleId is deprecated, use topic instead
0|parse-se | node-pre-gyp WARN parse-server-push-adapter APNS bundleId is deprecated, use topic instead
0|parse-se | node-pre-gyp WARN parse-server-push-adapter APNS bundleId is deprecated, use topic instead
0|parse-se | node-pre-gyp WARN parse-server-push-adapter APNS bundleId is deprecated, use topic instead

Note that it work for Android and IOS before that. For now it only work Android, by the way I use current version

parse-server-push-adapter": "2.0.0-alpha.1",

Support for progressive web apps

Can this support web push for progressive web apps.

Web push uses following package:

web push github

Service worker gives following data if user agreed to receive push notification:

{
            keys: {
                auth: "rhho****************cpNnXHA==",
                p256dh: "BLna57U_B28G0wgR8A4WIr4W***********************************PbVlalFB0GaaWJhxcnP_D8="
            },
            endpoint: "https://android.googleapis.com/gcm/send/cFiMEq3HtA0:APA91bE_*********************************************************************ybpiTP_We299husGnP-sc8i9C"
}

I do not know how this will integrate with existing system. But, it will be great if it could.

Push is not delivered to iOS device

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 (#4 (comment)).
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?

if no deviceToken, count is never decremented fully, and the PushStatus never marked success/fail

if I have no deviceToken assigned, and send a push to that Installation,
then in PushAdapterUtils.classifyInstallations:

// No deviceToken, ignore
if (!installation.deviceToken) {
continue;
}

completely shortcuts any attempted execution of push to these devices.

this is fine, but because the push is never sent, no response from the push service can decrement the count,
so it never completes, and PushStatus is left in a 'running' state with outstanding count equal to the number of null deviceToken records.

somewhere here, this needs to either drop the total count, or decrement the oustanding count,
or just drop the if/continue altogether.

Can not find sender for push type android/ios

This is my Server configuration:

var api = new ParseServer({
  serverURL: process.env.PARSE_SERVER_URL || 'http://localhost:1337/parse', // $
  databaseURI: process.env.PARSE_SERVER_DATABASE_URL || 'mongodb://localhost:27017/dev',
  cloud: process.env.PARSE_SERVER_CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.PARSE_SERVER_APPLICATION_ID || 'myAppId',
  masterKey: process.env.PARSE_SERVER_MASTER_KEY || '' //Add your master key here. Keep it secret!
  javascriptKey: process.env.PARSE_SERVER_JAVASCRIPT_KEY,
  restAPIKey: process.env.PARSE_SERVER_REST_API_KEY,
  dotNetKey: process.env.PARSE_SERVER_DOTNET_KEY,
  clientKey: process.env.PARSE_SERVER_CLIENT_KEY,

  push: {
    android: {
        senderId: process.env.PARSE_ANDROID_SENDERID,
        apiKey: process.env.PARSE_ANDROID_APIKEY
      },

    ios: [
      {
        pfx: process.env.PARSE_IOS_DEV_CERT,
        bundleId: process.env.PARSE_IOS_BUNDLEID,
        production:false // Dev
      },
      {
        pfx: process.env.PARSE_IOS_PROD_CERT,
        bundleId: process.env.PARSE_IOS_BUNDLEID,
        production:true // Prod
      }
    ]
  }

});

Push doesn't work, both on iOS and Android (with parse-server-example everything works with the same configuration).

This is the log:

verbose: sending push to 6 installations
verb parse-server-push-adapter Can not find sender for push type ios, [object Object]
verb parse-server-push-adapter Can not find sender for push type android, [object Object]
verbose: sent push! 0 success, 0 failures 

unable to send push notification to ios devices

I am getting below error. could you please guide me.
App/0verb parse-server-push-adapter APNS APNS Connection 0 Socket Error2016-09-15T17:22:18.430+0530
App/0 ^2016-09-15T17:22:18.449+0530
App/0 throw err;2016-09-15T17:22:18.449+0530
App/0Error: socket hang up2016-09-15T17:22:18.451+0530
App/0 at TLSSocket.onHangUp (_tls_wrap.js:1054:19)2016-09-15T17:22:18.451+0530
App/0 at TLSSocket.g (events.js:260:16)2016-09-15T17:22:18.451+0530
App/0 at endReadableNT (_stream_readable.js:921:12)2016-09-15T17:22:18.451+0530
App/0 at emitNone (events.js:72:20)2016-09-15T17:22:18.451+0530
App/0 at nextTickCallbackWith2Args (node.js:442:9)2016-09-15T17:22:18.451+0530
App/0 at process._tickDomainCallback (node.js:397:17)2016-09-15T17:22:18.452+0530
App/0npm ERR! Linux 3.19.0-33-generic2016-09-15T17:22:18.505+0530
App/0npm ERR! argv "/home/vcap/app/vendor/node/bin/node" "/home/vcap/app/vendor/node/bin/npm" "start"2016-09-15T17:22:18.506+0530
App/0npm ERR! node v4.5.02016-09-15T17:22:18.512+0530
App/0npm ERR! code ELIFECYCLE2016-09-15T17:22:18.516+0530
App/0 at TLSSocket.emit (events.js:166:7)2016-09-15T17:22:18.451+0530
App/0npm ERR! Exit status 72016-09-15T17:22:18.523+0530
App/0npm ERR! Failed at the [email protected] start script 'node index.js'.2016-09-15T17:22:18.523+0530
App/0npm ERR! This is most likely a problem with the parse-server-example package,2016-09-15T17:22:18.524+0530
App/0npm ERR! not with npm itself.2016-09-15T17:22:18.525+0530
App/0npm ERR! Tell the author that this fails on your system:2016-09-15T17:22:18.526+0530
App/0npm ERR! node index.js2016-09-15T17:22:18.526+0530
App/0npm ERR! npm bugs parse-server-example2016-09-15T17:22:18.528+0530
App/0npm ERR! You can get information on how to open an issue for this project with:2016-09-15T17:22:18.527+0530
App/0npm ERR! Or if that isn't available, you can get their info via:2016-09-15T17:22:18.529+0530
App/0npm ERR! 2016-09-15T17:22:18.530+0530
App/0npm ERR! npm owner ls parse-server-example2016-09-15T17:22:18.532+0530
App/0npm ERR! There is likely additional logging output above.2016-09-15T17:22:18.532+0530
App/0npm ERR! 2016-09-15T17:22:18.523+0530
App/0npm ERR! Please include the following file with any support request:2016-09-15T17:22:18.543+0530
App/0npm ERR! /home/vcap/app/npm-debug.log2016-09-15T17:22:18.544+0530
App/0npm ERR! npm v2.15.9

Remote notifications with an expiration date not being delivered

So my application is using the Parse platform to send notifications to different devices and to ensure that the device receives the notification I've added an expiration time to it.

This works sometimes whenever the device is in airplane mode but it almost never works whenever I switch the device off and turn it back on the notification doesn't get delivered to the device. Below are the steps I take to test this:

  • Put phone in airplane mode for more than 5 minutes and connect back to wifi: Sometimes the notification is delivered or it's delivered with a delay with no sound or vibrations.
  • Switch the phone off completely for more than 5 minutes and turn it back on: The notification is never delivered.

Like I mentioned I'm using the Parse SDK and I'm mainly using the cloud code which is written in JS to get the time 4 hours from now and create a date object from this since this is what is required for the expiration_time parameter.

Here is the code I'm using to get the time 4 hours from now.

// Expiration date
var now = new Date();
var futureTime = now.setHours(now.getHours() + 4);
var expireDate = new Date(futureTime);

Then I'm using an object to create my own payload since I want to use rich notifications within my iPhone application. Below is the structure of the JS object of the payload, note the expireDate used from above.

// Get the device from installations
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo("deviceToken", withToken);

// APNS Payload
var payload = {
    where: pushQuery,
    expiration_time: expireDate,
    data: {
        sound : "Wakeup.wav",
        aps: {
            alert: {
                title : "Good morning!",
                subtitle: "Today's forcast in " + withCity,
                body: withSummary
            },
           "mutable-content" : 1,
           icon: withIcon
        }
    }
};

Then this is just sent using the standard Parse push function as you can see below.

Parse.Push.send(payload,{ useMasterKey: true,
    success: function() {
        response.success("Successful push, future time: " + futureTime + " Date object: " + new Date(futureTime));
    },
    error: function(error) {
        response.error("Failed");
    }

});

I was just wondering if anyone could give any insight into why this may be happening at all? I don't know if this will help but the device I'm using is and it's current status is:

  • Device: iPhone 5
  • OS: iOS 10.2
  • Battery level: 49%

MismatchSenderId with multiple parse-server apps

parse-dashboard 1.0.26
parse-server 2.4.2

verbose: _PushStatus MuddERljo2: sending push to 1 installations
verb parse-server-push-adapter GCM sending to 1 device
verb parse-server-push-adapter GCM GCM Response: {
verb parse-server-push-adapter GCM     "multicast_id": 8880897755255961000,
verb parse-server-push-adapter GCM     "success": 0,
verb parse-server-push-adapter GCM     "failure": 1,
verb parse-server-push-adapter GCM     "canonical_ids": 0,
verb parse-server-push-adapter GCM     "results": [
verb parse-server-push-adapter GCM         {
verb parse-server-push-adapter GCM             "error": "MismatchSenderId"
verb parse-server-push-adapter GCM         }
verb parse-server-push-adapter GCM     ]
verb parse-server-push-adapter GCM }
verbose: _PushStatus MuddERljo2: sent push! 0 success, 1 failures

This only happens when there are multiple apps in the express server. Only the last parse-app successfully receives notifications. I can verify that all the api keys and sender ids are valid.

pushing to thousands of installations

Im currently sending push notifications to my app from my parse-server on DigitalOcean.

I have almost 20K installations and when I send a push to all of them, it takes almost 20 min to be received on the iphone.
In my case this is awfull because I notify soccer matches and users want to know as soon as their team scores a goal.
Ive seen on the parse-server documentation that push notifications "Does not support super high throughput since it does not employ a job queue system" and im assuming the server is sending push notifications one by one and thats why my console logs every second:

"Notification transmitted to:" + device.token.
But it takes to much time to receive the notification on the iPhone, I think my token is one of the last on that loop.

I would like to know if i can modify any file to avoid the loop and send the push notification faster, Ive found a file under parse-server/node_modules/apn/examples/sending-to-multiple-devices.js where I found this function

// If you plan on sending identical paylods to many devices you can do something like this.
function pushNotificationToMany() {
    console.log("Sending the same notification each of the devices with one call to pushNotification.");
    var note = new apn.notification();
    note.setAlertText("Hello, from node-apn!");
    note.badge = 1;

    service.pushNotification(note, tokens);
}

So. Is there a way i can call to this function from cloud code? because when I use Parse.Push.send() from cloud code I assume my server is using this other function (service.on) inside sending-to-multiple-devices.js and thats why i get that log on my console each second

service.on("transmitted", function(notification, device) {
    console.log("Notification transmitted to:" + device.token.toString("hex"));
});

Im currently using no adapters to push my notifications, Ive seen OneSignal is a great option but the problem is that users who dont update the app will still be hitting parse installations records (so their subscriptions to soccer teams might be modified and I wouldnt be capable of noticing it) I would be really happy if theres an alternative in wich I dont have to implement any Push Adapter

Sorry for my english

apns feedback service

please add in support for the apns feedback service so that periodically, deregistered devices are cleaned out of the database, thankyou!

Socket error when sending iOS notifications

Using NodeJS 7.0, PM2 and latest Parse server & parse-server-push-adapter on DigitalOcean I get socket error. Firewall is not a problem as outgoing connections are not blocked. (That's using verbose logging). Any idea what's happening? I've tested the certificate differently and it works, but doesn't work using parse. PUSH configuration sample I'm using:

  "PARSE_SERVER_PUSH": {
    android: {
      senderId: '',
      apiKey: ''
    },
    ios: [
    {
      pfx: '',
      bundleId: '',
      production: false
      },
    {
      pfx: '', 
      bundleId: '',  
      production: true
    }
    ]
  }

Any help is appreciated!

throw _iteratorError

I am running version 1.2.0 of parse-server-push-adapter. I added osx push config to my server configuration. Now the app crashes on startup with throw _iteratorError.

2017-03-14T14:56:39.663970+00:00 heroku[web.1]: Starting process with command `npm start`
2017-03-14T14:56:42.403842+00:00 app[web.1]:
2017-03-14T14:56:42.403855+00:00 app[web.1]: > [email protected] start /app
2017-03-14T14:56:42.403856+00:00 app[web.1]: > node index.js
2017-03-14T14:56:42.403857+00:00 app[web.1]:
2017-03-14T14:56:44.369047+00:00 app[web.1]:
2017-03-14T14:56:44.369063+00:00 app[web.1]: /app/node_modules/parse-server-push-adapter/lib/ParsePushAdapter.js:81
2017-03-14T14:56:44.369064+00:00 app[web.1]:           throw _iteratorError;
2017-03-14T14:56:44.369065+00:00 app[web.1]:           ^
2017-03-14T14:56:44.369066+00:00 app[web.1]: [object Object]
2017-03-14T14:56:44.383983+00:00 app[web.1]:
2017-03-14T14:56:44.394205+00:00 app[web.1]: npm ERR! Linux 3.13.0-112-generic
2017-03-14T14:56:44.394396+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2017-03-14T14:56:44.394542+00:00 app[web.1]: npm ERR! node v7.7.2
2017-03-14T14:56:44.394668+00:00 app[web.1]: npm ERR! npm  v4.1.2
2017-03-14T14:56:44.394837+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-03-14T14:56:44.395060+00:00 app[web.1]: npm ERR! [email protected] start: `node index.js`
2017-03-14T14:56:44.395160+00:00 app[web.1]: npm ERR! Exit status 1
2017-03-14T14:56:44.395291+00:00 app[web.1]: npm ERR!
2017-03-14T14:56:44.395379+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node index.js'.
2017-03-14T14:56:44.395468+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2017-03-14T14:56:44.395560+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the podlive-parse-server package,
2017-03-14T14:56:44.395649+00:00 app[web.1]: npm ERR! not with npm itself.
2017-03-14T14:56:44.395744+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2017-03-14T14:56:44.395831+00:00 app[web.1]: npm ERR!     node index.js
2017-03-14T14:56:44.395920+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2017-03-14T14:56:44.396011+00:00 app[web.1]: npm ERR!     npm bugs podlive-parse-server
2017-03-14T14:56:44.396098+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2017-03-14T14:56:44.396186+00:00 app[web.1]: npm ERR!     npm owner ls podlive-parse-server
2017-03-14T14:56:44.396275+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2017-03-14T14:56:44.405248+00:00 app[web.1]:
2017-03-14T14:56:44.405608+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2017-03-14T14:56:44.405803+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2017-03-14T14:56:46.493610+00:00 heroku[web.1]: State changed from starting to crashed
2017-03-14T14:56:46.483890+00:00 heroku[web.1]: Process exited with status 1

This is how my push config does look like:

  push: {
    ios: {
      pfx: __dirname + '/certs/' + process.env.APNS_IOS_CERTIFICATE, // The filename of private key and certificate in PFX or PKCS12 format from disk  
      bundleId: process.env.BUNDLE_ID_IOS, // The bundle identifier associate with your app
      production: is_production // Specifies which environment to connect to: Production (if true) or Sandbox
    },
    osx: {
      pfx: __dirname + '/certs/' + process.env.APNS_OSX_CERTIFICATE, // The filename of private key and certificate in PFX or PKCS12 format from disk  
      bundleId: process.env.BUNDLE_ID_OSX, // The bundle identifier associate with your app
      production: is_production // Specifies which environment to connect to: Production (if true) or Sandbox
    }
  },

All configuration variables are set.

Expected:

parse server push adapter should throw an error that osx is unsupported push type as this is only supported with release 1.3.0.

Actual result:

It crashes with throw _iteratorError;.

thoughts:

I think _iteratorError in this case is actually the correct error I expect ( throw new Parse.Error(Parse.Error.PUSH_MISCONFIGURED, 'Push to ' + pushType + ' is not supported');. However parse server does not print the error correctly to the user as you can see here: https://github.com/ParsePlatform/parse-server/blob/c1dcaf12712eb025d502387e564d3b9c1093a768/src/Adapters/AdapterLoader.js

Therefore I never see the actual error message. Maybe this is an error of parse-server in this case.

node-pre-gyp verb parse-server-push-adapter Can not find sender for push type ios, [object Object]

2017-07-04T14:05:43.109411+00:00 app[web.1]: �[36mverbose�[39m: REQUEST for [POST] /parse/push: {

2017-07-04T14:05:43.109422+00:00 app[web.1]: "where": {

2017-07-04T14:05:43.109423+00:00 app[web.1]: "deviceType": {

2017-07-04T14:05:43.109424+00:00 app[web.1]: "$in": [

2017-07-04T14:05:43.109424+00:00 app[web.1]: "ios"

2017-07-04T14:05:43.109425+00:00 app[web.1]: ]

2017-07-04T14:05:43.109426+00:00 app[web.1]: }

2017-07-04T14:05:43.109426+00:00 app[web.1]: },

2017-07-04T14:05:43.109427+00:00 app[web.1]: "data": {

2017-07-04T14:05:43.109428+00:00 app[web.1]: "alert": "asfaffasfasfaasgag"

2017-07-04T14:05:43.109429+00:00 app[web.1]: }

2017-07-04T14:05:43.109430+00:00 app[web.1]: } method=POST, url=/parse/push, host=demarkeservice.herokuapp.com, connection=close, content-type=text/plain, origin=http://0.0.0.0:4040, accept-encoding=gzip, deflate, accept=/, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4, referer=http://0.0.0.0:4040/apps/79BD4467-64BE-499B-9143-28A6436B978B/push/new, accept-language=en-us, x-request-id=3810da40-4073-498e-8c17-c77132f61a03, x-forwarded-for=176.240.106.229, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=1, x-request-start=1499177143097, total-route-time=0, content-length=270, $in=[ios], alert=asfaffasfasfaasgag

2017-07-04T14:05:43.127192+00:00 app[web.1]: �[36mverbose�[39m: RESPONSE from [POST] /parse/push: {

2017-07-04T14:05:43.127196+00:00 app[web.1]: "headers": {

2017-07-04T14:05:43.127197+00:00 app[web.1]: "X-Parse-Push-Status-Id": "zx6plwYx8l"

2017-07-04T14:05:43.127197+00:00 app[web.1]: },

2017-07-04T14:05:43.127198+00:00 app[web.1]: "response": {

2017-07-04T14:05:43.127199+00:00 app[web.1]: "result": true

2017-07-04T14:05:43.127199+00:00 app[web.1]: }

2017-07-04T14:05:43.127200+00:00 app[web.1]: } X-Parse-Push-Status-Id=zx6plwYx8l, result=true

2017-07-04T14:05:43.138862+00:00 app[web.1]: �[36mverbose�[39m: _PushStatus zx6plwYx8l: sending push to 1 installations

2017-07-04T14:05:43.156644+00:00 app[web.1]: node-pre-gyp verb parse-server-push-adapter Can not find sender for push type ios, [object Object]

2017-07-04T14:05:43.157589+00:00 app[web.1]: �[36mverbose�[39m: _PushStatus zx6plwYx8l: sent push! 0 success, 1 failures

Disconnected from log stream. There may be events happening that you do not see here! Attempting to reconnect...

2017-07-04T14:05:43.127192+00:00 app[web.1]: �[36mverbose�[39m: RESPONSE from [POST] /parse/push: {

2017-07-04T14:05:43.127196+00:00 app[web.1]: "headers": {

2017-07-04T14:05:43.127197+00:00 app[web.1]: "X-Parse-Push-Status-Id": "zx6plwYx8l"

2017-07-04T14:05:43.127197+00:00 app[web.1]: },

2017-07-04T14:05:43.127198+00:00 app[web.1]: "response": {

2017-07-04T14:05:43.127199+00:00 app[web.1]: "result": true

2017-07-04T14:05:43.127199+00:00 app[web.1]: }

2017-07-04T14:05:43.127200+00:00 app[web.1]: } X-Parse-Push-Status-Id=zx6plwYx8l, result=true

2017-07-04T14:05:43.138862+00:00 app[web.1]: �[36mverbose�[39m: _PushStatus zx6plwYx8l: sending push to 1 installations

2017-07-04T14:05:43.156644+00:00 app[web.1]: node-pre-gyp verb parse-server-push-adapter Can not find sender for push type ios, [object Object]

2017-07-04T14:05:43.157589+00:00 app[web.1]: �[36mverbose�[39m: _PushStatus zx6plwYx8l: sent push! 0 success, 1 failures

Push Notifications support for OS X, tvOS

This issue is for tracking an improvement to classic ParsePushAdapter to add support for OS X (which is supported on classic Parse), and tvOS (which is not).

Adding support for these would be very trivial, since we have iOS Push Notifications working, and would require changes to a few things:

  • Add support for osx and tvos deviceTypes to installation
  • Add support to ParsePushAdapter and APNS.js to accept more than just iOS certificates.
  • Add support to ParsePushAdapter and APNS.js to send to tvOS, which reuses the same certificate as iOS.
    Comment here, subscribe to this issue or send a PR to implement any part of this.

Originally parse-community/parse-server#571

cc: @nlutsenko

mutable-content 1 outside the aps scope

I am sorry for this question, i am new to parse and js, i want to make my pushes available with images for iOS 10 but looks like i do something wrong with setting params, please help:

Parse.Push.send({
        where: pushQuery, // Set our Installation query
        data: {
            alert: alertMessage,
            sound: "default",
            "content-available": 1,
            "mutable-content": 1,
            "image": "https://hsto.org/files/ff5/03e/e6b/ff503ee6b45d46ffb092aac33f2f282b.gif"
        }
    }, {
            useMasterKey: true,
            success: function () {
                response.success("Push sent to everyone with image!");
            },
            error: function (error) {
                response.error("Error sending push: " + error);
            }
        });

and i getting this on device :

{
    aps =     {
        alert = "Test text!";
        "content-available" = 1;
        sound = default;
    };
    image = "https://hsto.org/files/ff5/03e/e6b/ff503ee6b45d46ffb092aac33f2f282b.gif";
    "mutable-content" = 1;
}

is not "mutable-content" = 1; must be in scope of aps ? If it is, what i doing wrong ?

FCM adapter

How would we go about developing a push adapter for FCM. Projects created in Google Console seem to now be required to use Firebase Cloud Messaging instead of GCM. I've tried to start an FCM adapter by copying the GCM adapter where I could but I'm changing certain parts when needed based on fcm-node documentation.

New release for `mutableContent`

Hi there,

Is it possible to cut a new release for the latest changes that support mutable-content in APNS? Presumably this will be version 1.1.0 as the interface has changed. Shall I submit a PR?

Thanks in advance

warning: error while sending push RangeError: Maximum call stack size exceeded

Initiale posted by @fabuhelow on parse-community/parse-server#1966

Hi All,

I'm trying to push a new notification to "140,000" users and I have got the following exception:

index-3 (out): info: warning: error while sending push RangeError: Maximum call stack size exceeded index-3 (out): at GCM.send (/parse-server-gcm/node_modules/parse-server-push-adapter/lib/GCM.js:51:42) index-3 (out): at _loop (/parse-server-gcm/node_modules/parse-server-push-adapter/lib/ParsePushAdapter.js:114:38) index-3 (out): at ParsePushAdapter.send (/parse-server-gcm/node_modules/parse-server-push-adapter/lib/ParsePushAdapter.js:120:9) index-3 (out): at PushController.sendToAdapter (/parse-server-gcm/node_modules/parse-server/lib/Controllers/PushController.js:171:27) index-3 (out): at /parse-server-gcm/node_modules/parse-server/lib/Controllers/PushController.js:128:23 index-3 (out): at run (/parse-server-gcm/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:89:22) index-3 (out): at /parse-server-gcm/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:102:28 index-3 (out): at flush (/parse-server-gcm/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9) index-3 (out): at _combinedTickCallback (internal/process/next_tick.js:67:7) index-3 (out): at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Server specifications:

  • PM2 Threads: 4
  • Server CPU's : 4
  • HDD Space: 8 GB, Used 3 GB, Free 5 GB

- RAM: 16 GB, Free 14 GB

Any help about this issue ?

Thanks,

push notification to channels except the current user

Hi I'm new to parse how can the user send a post and not receive the notification him self

var theMessage = request.params.message;
var theChannel = request.params.channels;
var theView = request.params.view;
var theTitle = request.params.thetitle;
var pushQuery = new Parse.Query(Parse.Installation);
pushQuery.equalTo('channels', theChannel);
pushQuery.notEqualTo('user', request.params.user);
Parse.Push.send({
where: pushQuery,
data: {
title: theTitle,
alert: theMessage,
view: theView,
badge: 1,
sound: 'default'
}
}, { useMasterKey: true }).then(function(){
response.success('Push ok');
}, function(error){
response.error('Push error');
});

This works fine but the sender also receives the push notifications.

Parse-Server Push Adapter FCM issue

During migration ,i have added these lines of codes in my index.js files for configuring the push for android using FCM: #41

push:{
fcm:{
senderId:"",
apiKey:"
*************"
}
}

But it throws | /home/ubuntu/parse-server/node_modules/parse-server-push-adapter/lib/ParsePushAdapter.js:80
0|npm | throw _iteratorError;

Is FCM supported in Parse Server? Is this Issue solved?

Push not sent to iOS Device

For implementation related questions or technical support, please refer to the Stack Overflow and Server Fault communities.

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Server!

Environment Setup

Heroku (Performace 1x) + mLab (Dedicated Cluster M3) running parse-server-example with parse-server 2.2.2

Steps to reproduce

`var api = new ParseServer({
databaseURI: databaseUri || '...',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '...',
masterKey: process.env.MASTER_KEY || '...', //Add your master key here. Keep it secret!
fileKey: ...', //This is needed to display old files on Parse's S3
serverURL: process.env.SERVER_URL || 'http://localhost:1337', // Set to correct url from heroku env
filesAdapter: new S3Adapter(
"...",
"...",
"...",
{directAccess: true, region:"s3-eu-west-1.amazonaws.com"}
),
push: {
ios: [
{
pfx: __dirname + '/development.p12', // Prod PFX or P12
bundleId: 'com.okaris.myapp',
production: false // Prod
},
{
pfx: __dirname + '/production.p12', // Prod PFX or P12
bundleId: 'com.okaris.myapp',
production: true // Prod
}
]
}

});`

Logs/Trace

2016-03-21T20:56:16.089931+00:00 app[web.1]: POST /parse/push { host: 'coralline.herokuapp.com', 2016-03-21T20:56:16.089940+00:00 app[web.1]: connection: 'close', 2016-03-21T20:56:16.089941+00:00 app[web.1]: 'user-agent': 'node-XMLHttpRequest, Parse/js1.8.1 (NodeJS 5.8.0)', 2016-03-21T20:56:16.089942+00:00 app[web.1]: accept: '*/*', 2016-03-21T20:56:16.089943+00:00 app[web.1]: 'content-type': 'text/plain', 2016-03-21T20:56:16.089951+00:00 app[web.1]: 'x-request-id': '9efc6deb-5c34-4e21-9dc1-8c7594f14090', 2016-03-21T20:56:16.089952+00:00 app[web.1]: 'x-forwarded-for': '54.74.165.67', 2016-03-21T20:56:16.089953+00:00 app[web.1]: 'x-forwarded-proto': 'https', 2016-03-21T20:56:16.089953+00:00 app[web.1]: 'x-forwarded-port': '443', 2016-03-21T20:56:16.089954+00:00 app[web.1]: via: '1.1 vegur', 2016-03-21T20:56:16.089954+00:00 app[web.1]: 'connect-time': '0', 2016-03-21T20:56:16.089955+00:00 app[web.1]: 'x-request-start': '1458593776087', 2016-03-21T20:56:16.089956+00:00 app[web.1]: 'total-route-time': '0', 2016-03-21T20:56:16.089956+00:00 app[web.1]: 'content-length': '399' } { 2016-03-21T20:56:16.089957+00:00 app[web.1]: "where": { 2016-03-21T20:56:16.089958+00:00 app[web.1]: "user": { 2016-03-21T20:56:16.089958+00:00 app[web.1]: "__type": "Pointer", 2016-03-21T20:56:16.089959+00:00 app[web.1]: "className": "_User", 2016-03-21T20:56:16.089960+00:00 app[web.1]: "objectId": "BUCrtfWPdz" 2016-03-21T20:56:16.089960+00:00 app[web.1]: } 2016-03-21T20:56:16.089961+00:00 app[web.1]: }, 2016-03-21T20:56:16.089962+00:00 app[web.1]: "data": { 2016-03-21T20:56:16.089962+00:00 app[web.1]: "alert": { 2016-03-21T20:56:16.089963+00:00 app[web.1]: "loc-key": "LikeNotification", 2016-03-21T20:56:16.089963+00:00 app[web.1]: "loc-args": [ 2016-03-21T20:56:16.089964+00:00 app[web.1]: "okaris", 2016-03-21T20:56:16.089965+00:00 app[web.1]: "O" 2016-03-21T20:56:16.089965+00:00 app[web.1]: ] 2016-03-21T20:56:16.089966+00:00 app[web.1]: }, 2016-03-21T20:56:16.089967+00:00 app[web.1]: "badge": "Increment", 2016-03-21T20:56:16.089967+00:00 app[web.1]: "sound": "PopDing.caf" 2016-03-21T20:56:16.089968+00:00 app[web.1]: } 2016-03-21T20:56:16.089969+00:00 app[web.1]: } 2016-03-21T20:56:16.092150+00:00 app[web.1]: response: { 2016-03-21T20:56:16.092160+00:00 app[web.1]: "response": { 2016-03-21T20:56:16.092161+00:00 app[web.1]: "result": true 2016-03-21T20:56:16.092162+00:00 app[web.1]: } 2016-03-21T20:56:16.092163+00:00 app[web.1]: } 2016-03-21T20:56:16.095961+00:00 app[web.1]: ##### PUSH OK

Server logs "PUSH OK" but I don't see any APNS Connection logs, no push is delivered. Tried with both production and development certificates. Certificates don't have passwords. Tried using empty android push config and not. Tried using CURL with same result.

Cloud Code:

var pushQuery = new Parse.Query(Parse.Installation, { useMasterKey: true }); pushQuery.equalTo('user', user); Parse.Push.send({ where: pushQuery, data: { alert: { "loc-key": "LikeNotificationNoContent", "loc-args": [sender.get('screenName')] }, badge: "Increment", sound: "PopDing.caf" } }, { success: function() { console.log('##### PUSH OK'); }, error: function(error) { console.log('##### PUSH ERROR' + error); }, useMasterKey: true });

Push Notifications Stuck @ verbose: _PushStatus : sending push to 1 installations - but dont get delivered.

Below is my code to send push notification , though it's success it doesnt get delivered to device.

Parse.Push.send({
where: {
"deviceType": {"$in": ["ios"]}
}, data: {
"title": "Registration",
"alert": "Push Notification working"
}
}, {
useMasterKey: true,
success: function() {
console.log("Push was Successful");
res.json("true")
},
error: function(error){
console.log(error)
}
});

Configuration:

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 || 'XXXX',
masterKey: process.env.MASTER_KEY || 'XXXX', //Add your master key here. Keep it secret!
serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
clientKey: process.env.CLIENT_KEY || 'XXXX',
liveQuery: {
classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
},
restAPIKey:"skillz",
verbose: true,
push: {
ios: {
pfx:'certs/services.p12',
topic: 'com.XXX.Skillz',
production:false,
passPhrase:'push'
}
}
});

Verbose Logs attached screenshot.

screen shot 2017-07-07 at 4 45 41 pm

Any help is really appreciated.

Push: GCM Canonical IDs

(originally posed on parse-community/parse-server#966 by @Dynogic)
Hi there,

I noticed that the GCM Push does not support canonical IDs yet. https://developers.google.com/cloud-messaging/registration#canonical-ids

Any idea to when it'll be implemented? Its very scary pushing current code into production when there could be possibilities of duplicate messages or complete push notification failure (the latter being a rare event where Google decides to change registration IDs. Quote from GCM docs: "If the registration token expires (for example, Google might decide to refresh registration tokens, or the APNS token has expired for iOS devices).")

Thanks,
Jake.

GCM push notifications restricted by DNS record/IP

Initially opened as parse-community/parse-server#1994 by @zgc7009

Describe your issue in as much detail as possible.

Note: DNS record and IP are interchangeable in our situation. We would like this to work specifically with DNS records, so it will be what we use. We are not sure this is a Parse issue but thought it was worth posting. Obviously, if it is a non-Parse issue feel free to close.

Due to the impact this migration can have on our clients, we are hoping to do a rollout of our application. To do this, we have asked a number of our clients to utilize the web portion of our app from a beta formatted DNS that is pointed to our Parse server while others continue to use the old DNS record that is pointed to the Parse maintained server, while both servers are pointing to the same mLab DB. Posting a message through the web app should trigger a push notification to the mobile applications. As a note, we do not plan on ever pointing our mobile apps to the beta DNS record, once we are done testing everything is going to get associated with the current live DNS record. The problem we are having is that GCM push notifications are only being received if the message is posted from the web app pointing to the same DNS record that the application itself is pointed at. For example, messages posted on our live web app are successfully pushing notifications to the Android app which is also pointed to live DNS record but if we attempt to post a message from the beta web app, the message will never get to the Android app that is pointed to the live DNS record.

Steps to reproduce

Please include a detailed list of steps that reproduce the issue. Include curl commands when applicable.

Note: this is a unique situation, the creation process would be fairly in depth

  1. Create an Android app and setup the GCM with Google Play
  2. Initialize the Android app with an official Parse server (using Parse.com’s GCM credentials)
  3. Host Cloud Code in /cloud directory of open source Parse-Server instance
  4. Point both Parse servers to a single Mongo database
  5. Call Parse.Push.send({ ... }, {useMasterKey: true}) within the Cloud Code

Expected Results

All mobile users will receive a push notification that a message was posted from the web app to the Parse server.

Actual Outcome

The push appears to go out, iOS even successfully gets the push, but Android does not receive the push notification.

Environment Setup

  • Server
    • parse-server version: 2.2.0
    • Operating System: Amazon Linux AMI, Windows Server 2012 R2 AMI
    • Hardware: t2.large (2 vCPU, 8 Mem(GiB))
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): AWS (EBS)
  • Database
    • MongoDB version: 3.0.11
    • Storage engine: MMAP
    • Hardware: M1 Cluster (1.7 GB RAM, 40 GB SSD storage)
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): mLab

      Logs/Trace

You can turn on additional logging by configuring VERBOSE=1 in your environment.

  • No relevant log seen

Support title payload on iOS notifications

About the push notification title parameter, the docs says it's only sent to Android devices, but it's supported since iOS 8.2.

I was wondering if Parse really doesn't send it for iOS devices or it's just the docs that are outdated, but I couldn't find any mention to it in the source files.

Is it planned or was it discarded for some reason? Should I try to make a PR?

APNS adapter failure -- cannot find valid connection

I receive the following error: "ERR! parse-server-push-adapter APNS cannot find vaild connection for "
when trying to debug push notifications on a local server environment. Note that with the same .p12 key /certificate, I can successfully push notifications to APNS and the same iPhone via a php script running locally.

Environment Setup

parse server 2.27 running on OSX

Steps to reproduce

configure with one installation from app, start server locally with pfx config pointed to .p12 file.
start a APNS push via curl or the parse-dashboard.

Logs/Trace

"verbose: sending push to 1 installations
ERR! parse-server-push-adapter APNS cannot find vaild connection for 768dfdea3b13c3f2ab64dcf3d5fc82e4dd5081189e8d98bf848fa579b848c1a1
/usr/local/lib/node_modules/parse-server/lib/ParseServer.js:329
throw err;
^

Error: mac verify failure
at Error (native)
at Object.createSecureContext (_tls_common.js:132:17)
at Object.TLSSocket._init.ssl.onclienthello.ssl.oncertcb.exports.connect (_tls_wrap.js:972:23)
at apnSocket (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/socket.js:56:19)
at Connection. (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:199:17)
at _fulfilled (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:796:13)
at /usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:604:44
at runSingle (/usr/local/lib/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:137:13)

GCM error 401 when sending a push via adapter

Edit: I solved it as follows:
Apparently GCM changed the way you create API keys. They no longer let you choose between server, browser, etc.. But I think their default doesn't whitelist all IPs so once I explicitly added my local public IP and my server's public IP I stopped getting this error.

Hi,
I'm trying to send a push using the default GCM adapter.
I get an 401 error.
My server config is configured ok, I know this because the correct apiKey is used when needed in the adapter (when I'm debugging).

What I find strange, is that in no place, the senderId is used

on init this code is executed:

function GCM(args) {
  if ((typeof args === 'undefined' ? 'undefined' : _typeof(args)) !== 'object' || !args.apiKey) {
    throw new _parse2.default.Error(_parse2.default.Error.PUSH_MISCONFIGURED, 'GCM Configuration is invalid');
  }
  this.sender = new _nodeGcm2.default.Sender(args.apiKey);
}

args holdes the proper apiKey and senderId but the senderId is disregarded and the this.sender only takes the apiKey. I've not found any code use for senderId.

I'm running parse-server version 2.2.17

note that I've noticed that google API changed their API key usage a bit, and not instead of choosing between ios,server, browser or android - the default is simply creating a non-restricted API key, which is what I did.
Triple checked the API key, and generated new ones and tried them as well...
Waited 5 minutes.
and then that 401 error.

Anyone have a clue or direction?

Parse-Server Crash on APNs Timeout

Transferred from parse-community/parse-server#3637

Issue Description

Using the REST endpoint for sending APNS push, sometimes the service times out and causes parse-server to crash...

Steps to reproduce

Just running this following curl a few times until the app crashes:

curl -H 'X-Parse-Application-Id: XXX' \
     -H 'X-Parse-Master-Key: XXX' \
     -d '{"where": {"user": {"$inQuery": {"className": "_User", "where": {"objectId": {"$in": ["UID1", "UID2"]}}}}}, "data": {"title": "my title", "alert": "mi alert"}}' \
     'http://localhost:1337/parse/push'

Expected Results

parse-server should catch the exception and either retry or fail with an error message (not crash the whole process).

Actual Outcome

parse-server is crashing on:

/parse/node_modules/parse-server/lib/ParseServer.js:401
            throw err;
            ^

Error: Connect timed out
    at Connection.<anonymous> (/parse/node_modules/apn/lib/connection.js:226:36)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

Environment Setup

  • Server

    • parse-server version: 2.2.22
    • Operating System: ubuntu 14.04
    • Hardware: AWS t2.medium
    • Localhost or remote server?: AWS
  • Database

    • MongoDB version: 3.0.9
    • Storage engine: S3
    • Hardware: Ubuntu 14.04
    • Localhost or remote server?: ObjectRocket

Logs/Trace

I caught two types of crashes:

ERR! parse-server-push-adapter APNS cannot find vaild connection for b73bd323f4e1a5427a82e2463c79e0b9cb34f95e8154e78ce7a2511021282ec5
/parse/node_modules/parse-server/lib/ParseServer.js:401
            throw err;
            ^

Error: certificate has expired: 2017-03-09T07:49:49.000Z
    at validateCredentials (/parse/node_modules/apn/lib/credentials/validate.js:12:9)
    at /parse/node_modules/apn/lib/connection.js:163:5
    at _fulfilled (/parse/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/parse/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/parse/node_modules/q/q.js:796:13)
    at /parse/node_modules/q/q.js:604:44
    at runSingle (/parse/node_modules/q/q.js:137:13)
    at flush (/parse/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

But my certificate is not expired - retrying works.

and:

/parse/node_modules/parse-server/lib/ParseServer.js:401
            throw err;
            ^

Error: Connect timed out
    at Connection.<anonymous> (/parse/node_modules/apn/lib/connection.js:226:36)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)

just timing out on the connection.

Push Notifications - iOS - expiration_time

Initially Opened by @alistairbrightec as parse-community/parse-server#1959

When sending a push notification from cloud code to an iOS device, the cloud function returns successful however the server crashes with the following:

at flush (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:125:13) at runSingle (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:137:13) at /bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:1391:14 at Promise.promise.promiseDispatch (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:788:41) at Promise.apply (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/node_modules/q/q.js:1165:26) at Connection. (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:287:8) at Connection.serviceBuffer (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:330:13) at Connection.transmitNotification (/bundle/node_modules/parse-server/node_modules/parse-server-push-adapter/node_modules/apn/lib/connection.js:691:8) at Buffer.writeUInt32BE (buffer.js:923:5) at checkInt (buffer.js:830:11) TypeError: value is out of bounds ^ throw err; /bundle/node_modules/parse-server/lib/ParseServer.js:333

After digging into it, it only crashes if we include the line:

var oneWeekAway = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000); ..... expiration_time: oneWeekAway,

The server I am using is one hosted by https://www.nodechef.com/parse-server and they requested that I posted this issue here

Steps to reproduce

  1. Add expiration_time into a push sent to an iOS device

Expected Results

No crash, send push notification, cloud function returns successfully

Actual Outcome

Server crashes and the cloud function returns successfully

Environment Setup

  • Server
    • parse-server version: 2.2.10
    • Operating System: Unknown
    • Hardware: Unknown
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Unknown
  • Database
    • MongoDB version: Unknown
    • Storage engine: Unknown
    • Hardware: Unknown
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): Unknown

Logs/Trace

Unknown

GCM not supported anymore

Google is now using FCM only to enable push notifications on android. FCM API key and senderId are not valid in GCM, gives 401 and API Key not found error. So this adapter is deprecated now for new users. Is there anyone with whom i can create new one ? Know how to create FCM adapter based on doc and current GCM adapter, but missing skills to add it to project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.