Skip to content

Push Notifications - working via REST, not via cloud code #3022

Closed
@ethandrower

Description

@ethandrower

#Describe your issue in as much detail as possible.

I’m running parse-server on ubuntu and can't seem to get push notifications working when sent in cloud code, even though they are succeeding in the logs.

Pushes work (and are received by the devices ) when using a REST api call (passing master key) but don't work when cloud code calls them. This is what leads me to believe I am having a parse problem vs. an apple/iOS problem.

What's interesting is that the cloud code Parse.Push() method returns a success and thus no error message. In verbose logging, you can even see the connections initiated with the correct deviceIDs

Here is my cloud function, the success callback in cloud is always called(unless I deliberately make the serverURL variable something incorrect). Pushes are just never delivered to the devices.

Parse.Push.send(
{
// where: pushQueryClient,
channels: ["user_tkP7gurGzc"], //this is a specific user who is subscribed to this channel.
data:
{
alert: pushTextClient
}
},
{
success:function(){
console.log("push sent");
},
error: function(error){
console.log("push failed");
console.dir(error);
},

useMasterKey: true});

Here are the verbose logs showing the push being sent successfully
verbose: REQUEST for [POST] /parse/push: {
"channels": [
"user_tkP7gurGzc"
],
"data": {
"alert": ""
}
} method=POST, url=/parse/push, user-agent=node-XMLHttpRequest, Parse/js1.9.2 (NodeJS 4.5.0), accept=/, content-type=text/plain, host=localhost:1337, content-length=252, connection=close, channels=[user_tkP7gurGzc], alert=
verbose: REQUEST for [POST] /parse/push: {
"channels": [
"user_HFxoncoHal"
],
"data": {
"alert": ""
}
} method=POST, url=/parse/push, user-agent=node-XMLHttpRequest, Parse/js1.9.2 (NodeJS 4.5.0), accept=/, content-type=text/plain, host=localhost:1337, content-length=252, connection=close, channels=[user_HFxoncoHal], alert=
verbose: RESPONSE from [POST] /parse/push: {
"headers": {
"X-Parse-Push-Status-Id": "6JmxBBF6Ws"
},
"response": {
"result": true
}
} X-Parse-Push-Status-Id=6JmxBBF6Ws, result=true
verbose: RESPONSE from [POST] /parse/push: {
"headers": {
"X-Parse-Push-Status-Id": "MsDOblnESX"
},
"response": {
"result": true
}
} X-Parse-Push-Status-Id=MsDOblnESX, result=true
verbose: sending push to 2 installations
verbose: sending push to 1 installations

verb parse-server-push-adapter APNS APNS Connection 0 Connected
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to e2c1bf254f2d855a475733fb9dcec0cf359a864ae6b8c5d1812832d9b51f6831
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to 8d9d36819a129251452b1a8ae722d2c8ae43e4c0864498e4983081f50cdd1f88
verbose: sent push! 2 success, 0 failures
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to ae7ff32c8df269b65819941338c83a2a94d73cb0ac8efbaf37cea4c0fad14f56
verbose: sent push! 1 success, 0 failures

Here is the curl that works along with corresponding verbose logs:

curl -X POST -H "X-Parse-Application-Id: myappid" -H "X-Parse-Master-Key: mymaster" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"channels": ["user_tkP7gurGzc"],
"data": {
"alert": "work!"
}
}' "http://mydomainname.com:1337/parse/push"

Here are the verbose logs when I use the rest api to send a push

verbose: REQUEST for [POST] /parse/push: {
"channels": [
"user_tkP7gurGzc"
],
"data": {
"alert": "work!"
}
} method=POST, url=/parse/push, host=myhost.com:1337, connection=keep-alive, content-length=76, origin=chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop, postman-token=11fdced1-045e-3953-d71d-60e0567dd7e6, cache-control=no-cache, x-parse-master-key=masterkey, x-parse-application-id=appid, user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36, content-type=application/json, accept=/, accept-encoding=gzip, deflate, accept-language=en-US,en;q=0.8, channels=[user_tkP7gurGzc], alert=work!
verbose: RESPONSE from [POST] /parse/push: {
"headers": {
"X-Parse-Push-Status-Id": "2SNIe7Eiba"
},
"response": {
"result": true
}
} X-Parse-Push-Status-Id=2SNIe7Eiba, result=true
verbose: sending push to 2 installations
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to e2c1bf254f2d855a475733fb9dcec0cf359a864ae6b8c5d1812832d9b51f6831
verb parse-server-push-adapter APNS APNS Connection 0 Notification transmitted to 8d9d36819a129251452b1a8ae722d2c8ae43e4c0864498e4983081f50cdd1f88
verbose: sent push! 2 success, 0 failures

Steps to reproduce

This occurs when cloud code is executed (on an afterSave trigger), and the success function defined above is called.

Expected Results

With the success function being called, I'd expect the notifications to be sent to the device, especially since push's sent via a REST call to parse work and are received on the devices.

Actual Outcome

No errors in parse logs, no notifications received by devices.

I guess my real question at this point: Are push notifications sent differently if the call is initiated from cloud code vs. the REST api?

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 2.15.9
      I realize this is not the most up to date according the versions doc, but it is the highest upgrade available via npm update.
    • Operating System: "Ubuntu 14.04.5 LTS"
    • Hardware: Digital Ocean, middle tier VM
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): localhost
  • Database

    • MongoDB version: 3.0.12
    • Storage engine: "name" : "mmapv1"
    • Hardware: run locally on same Digital Ocean VM
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): localhost

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