-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Push Notifications - working via REST, not via cloud code #3022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Why this issue closed? I hit exactly same issue, how did you solve this? |
I hit exactly same issue too... pls help me to solve this issue.. |
Please check there are no Client Keys / Javascript keys in your Parse Server initialization script. |
I have updated Parse Server, and updated NodeJS. Same error here 😢 |
@drew-gross Can you help us out? |
One thing that tripped me up earlier, was that you need to make sure your push certs with Apple are working properly. If you're in development still make sure each individual device is registered, and added to an ad-hoc provisioning certificate. When there was a problem with my cert, I saw delivery successes in the parse log but never got any on the device. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
When I first start the server, I am getting this message: WARNING, Unable to connect to 'https://127.0.0.1:1337/parse'. Cloud code and push notifications may be unavailable! When I send push notification using above method, I am getting this error message: 'XMLHttpRequest failed: "Unable to connect to the Parse API"' Did anyone face this issue, or can anyone help me with this? |
@nareninindia this is not a notification issue. |
@georgesjamous Thank you. Your comment helped me resolve the issue. Problem is with initialisation. |
#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
I realize this is not the most up to date according the versions doc, but it is the highest upgrade available via npm update.
Database
The text was updated successfully, but these errors were encountered: