Skip to content
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

Push PHP - No errors, no push delivered. cURL works ok! #644

Closed
Copyrightsworld opened this issue Feb 25, 2016 · 12 comments
Closed

Push PHP - No errors, no push delivered. cURL works ok! #644

Copyrightsworld opened this issue Feb 25, 2016 · 12 comments
Labels
type:question Support or code-level question

Comments

@Copyrightsworld
Copy link

Thank you @gfosco . I did what you said on #421 and now i get no errors.

Here is the trick though. When i use the cURL code from http://blog.parse.com/announcements/parse-server-push-notifications/ to test my server, i DO receive the notification on my phone.

When i try to push via code (php), i get NO errors on my heroku logs, but no notification is delivered (this code was working when i was on Parse hosting).

Any thoughts on that?

Thnx again.

@fraxool
Copy link

fraxool commented Feb 25, 2016

@globyworks can you paste your PHP code ? I got some troubles making my Parse push notifications to work with my parse-server with PHP, but now, everything works for me.

If you put your code, I will maybe be able to help you 👍

@Copyrightsworld
Copy link
Author

Thank you @fraxool for the reply.

Here is my code:

$data = array(
"alert" => "message",
"badge" => "Increment",
"sound" => "cheering.caf",
"title" => "title",
"fix_id"=> $fix_id, 'these are some custom parameters i pass
"n_t"=>"2" 'these are some custom parameters i pass
);

ParsePush::send(array(
"channels" => "channel name",
"data" => $data
),true);

@Copyrightsworld
Copy link
Author

Hi @fraxool again.
Just something to add to the info. When i use the cURL code to send the push, the push gets delivered to my phone.
Heroku logs thought outputs this:
"2016-02-25T14:56:08.805902+00:00 app[web.1]: APNS Connection 0 Notification transmitted to 8199bb4102cd2097404ed6d067ab3fa92654d9e8df531a0010c024d2b58a4d96
2016-02-25T14:56:08.703136+00:00 app[web.1]: APNS Connection 0 Connected"

I find this strange.

PHP code still returns no errors but sends no push.

Tnx.

@fraxool
Copy link

fraxool commented Feb 26, 2016

Hi @globyworks

Sorry for the delay. In fact, just after I posted my message, I tested the notification on my phone and it didn't work anymore. After a few moments, I detected that my Apple certificate was not valid anymore.

About your issue, I see something strange in your PHP code, not sure if it's that (since I don't use notifications with channels) but you should try :

ParsePush::send(array(
"channels" => ["channel name"],
"data" => $data
),true);

From the documentation, it seems like the channels have to be set as an array.

Let me know if it fixes it or not.

@Copyrightsworld
Copy link
Author

My bad here. When i pasted the code, i changed the channel name but forgot to enter the [].
So, this is what i have in my code and it does not work.

I was thinking that maybe the Certification, but again, if the certifications was the problem, then the cURL code would not work either, right ?

@gfosco
Copy link
Contributor

gfosco commented Feb 26, 2016

@globyworks can you set the environment variable VERBOSE=1 and make the curl request and the PHP request and compare the requests made to the server?

@Copyrightsworld
Copy link
Author

PHP request
"
2016-02-26T17:04:39.819457+00:00 app[web.1]: POST /parse/push { host: 'my-server.herokuapp.com',
2016-02-26T17:04:39.819465+00:00 app[web.1]: 'x-parse-application-id': 'VGsr3Id2jv6w4lSqH1txmBsxM9JNUn4xqdQBfqY5',
2016-02-26T17:04:39.819468+00:00 app[web.1]: 'content-type': 'application/json',
2016-02-26T17:04:39.819467+00:00 app[web.1]: 'x-parse-master-key': 'xxxxxxxxxxxxxxxxxxxxxx',
2016-02-26T17:04:39.819462+00:00 app[web.1]: connection: 'close',
2016-02-26T17:04:39.819466+00:00 app[web.1]: 'x-parse-client-version': 'php1.1.10',
2016-02-26T17:04:39.819468+00:00 app[web.1]: 'x-request-id': 'a4d8070d-2e65-42fd-8c86-97a8b4bd4712',
2016-02-26T17:04:39.819469+00:00 app[web.1]: 'x-forwarded-for': '46.177.32.188',
2016-02-26T17:04:39.819470+00:00 app[web.1]: 'x-forwarded-proto': 'https',
2016-02-26T17:04:39.819470+00:00 app[web.1]: 'x-forwarded-port': '443',
2016-02-26T17:04:39.819471+00:00 app[web.1]: via: '1.1 vegur',
2016-02-26T17:04:39.819471+00:00 app[web.1]: 'connect-time': '0',
2016-02-26T17:04:39.819472+00:00 app[web.1]: 'x-request-start': '1456506279806',
2016-02-26T17:04:39.819473+00:00 app[web.1]: 'total-route-time': '0',
2016-02-26T17:04:39.819473+00:00 app[web.1]: 'content-length': '166' } {
2016-02-26T17:04:39.819474+00:00 app[web.1]: "channels": [
2016-02-26T17:04:39.819475+00:00 app[web.1]: "nWQQiNaAFR"
2016-02-26T17:04:39.819476+00:00 app[web.1]: ],
2016-02-26T17:04:39.819476+00:00 app[web.1]: "data": {
2016-02-26T17:04:39.819477+00:00 app[web.1]: "alert": "Report status has changed!",
2016-02-26T17:04:39.819478+00:00 app[web.1]: "badge": "Increment",
2016-02-26T17:04:39.819478+00:00 app[web.1]: "sound": "cheering.caf",
2016-02-26T17:04:39.819479+00:00 app[web.1]: "title": "TITLE",
2016-02-26T17:04:39.819480+00:00 app[web.1]: "fix_id": "xe3vLuht06",
2016-02-26T17:04:39.819480+00:00 app[web.1]: "n_t": "2"
2016-02-26T17:04:39.819481+00:00 app[web.1]: }
2016-02-26T17:04:39.819481+00:00 app[web.1]: }
2016-02-26T17:04:39.821169+00:00 app[web.1]: response: {
2016-02-26T17:04:39.821172+00:00 app[web.1]: "result": true
2016-02-26T17:04:39.821173+00:00 app[web.1]: }
"

cURL request
"
2016-02-26T17:04:55.100168+00:00 app[web.1]: POST /parse/push { host: 'my-server.herokuapp.com',
2016-02-26T17:04:55.100173+00:00 app[web.1]: connection: 'close',
2016-02-26T17:04:55.100174+00:00 app[web.1]: 'user-agent': 'curl/7.43.0',
2016-02-26T17:04:55.100175+00:00 app[web.1]: accept: '/',
2016-02-26T17:04:55.100176+00:00 app[web.1]: 'x-parse-application-id': 'xxxxxxxxxxxxxxxxxxxxxx',
2016-02-26T17:04:55.100178+00:00 app[web.1]: 'content-type': 'application/json',
2016-02-26T17:04:55.100177+00:00 app[web.1]: 'x-parse-master-key': 'xxxxxxxxxxxxxxxxxxxxxx',
2016-02-26T17:04:55.100178+00:00 app[web.1]: 'x-request-id': '4f827659-43c9-44bf-93a0-493093ba0a17',
2016-02-26T17:04:55.100179+00:00 app[web.1]: 'x-forwarded-for': '46.177.32.188',
2016-02-26T17:04:55.100180+00:00 app[web.1]: 'x-forwarded-proto': 'http',
2016-02-26T17:04:55.100180+00:00 app[web.1]: 'x-forwarded-port': '80',
2016-02-26T17:04:55.100181+00:00 app[web.1]: via: '1.1 vegur',
2016-02-26T17:04:55.100183+00:00 app[web.1]: 'x-request-start': '1456506295089',
2016-02-26T17:04:55.100184+00:00 app[web.1]: 'total-route-time': '0',
2016-02-26T17:04:55.100184+00:00 app[web.1]: 'content-length': '317' } {
2016-02-26T17:04:55.100182+00:00 app[web.1]: 'connect-time': '1',
2016-02-26T17:04:55.100188+00:00 app[web.1]: "android"
2016-02-26T17:04:55.100187+00:00 app[web.1]: "$in": [
2016-02-26T17:04:55.100188+00:00 app[web.1]: ]
2016-02-26T17:04:55.100190+00:00 app[web.1]: },
2016-02-26T17:04:55.100186+00:00 app[web.1]: "deviceType": {
2016-02-26T17:04:55.100189+00:00 app[web.1]: }
2016-02-26T17:04:55.100190+00:00 app[web.1]: "data": {
2016-02-26T17:04:55.100191+00:00 app[web.1]: "title": "The Shining",
2016-02-26T17:04:55.100192+00:00 app[web.1]: "alert": "All work and no play makes Jack a dull boy."
2016-02-26T17:04:55.100607+00:00 app[web.1]: response: {
2016-02-26T17:04:55.100193+00:00 app[web.1]: }
2016-02-26T17:04:55.100610+00:00 app[web.1]: "result": true
2016-02-26T17:04:55.100185+00:00 app[web.1]: "where": {
2016-02-26T17:04:55.100192+00:00 app[web.1]: }
2016-02-26T17:04:55.100187+00:00 app[web.1]: "ios",
2016-02-26T17:04:55.100611+00:00 app[web.1]: }
2016-02-26T17:04:55.890786+00:00 app[web.1]: APNS Connection 0 Connected
2016-02-26T17:04:55.994923+00:00 app[web.1]: APNS Connection 0 Notification transmitted to 231eba4c80da5baa726263e837d8ce6e5c09f8fe1f9891e1eb5341bc36b364ac

"

A difference i spot, is that the cURL uses the Application-id as well, when php request uses only the master key. Not sure is that makes any actual difference though.

Any ideas ?

@Copyrightsworld
Copy link
Author

@gfosco @fraxool did you spot anything else on the logs above?

@mtrezza
Copy link
Member

mtrezza commented Feb 29, 2016

I have a similar issue in cloud code, the push gets delivered with a cURL but not in cloud code. Also I don't receive any server log in Heroku for the push in cloud code.

@fraxool
Copy link

fraxool commented Mar 3, 2016

Ok, I'm finally having the issue too from the Javascript Cloud Code on an Heroku server. The push notification is sent but not received on the targeted device.

Here is what I have in my Heroku log :

2016-03-03T12:46:07.623024+00:00 heroku[router]: at=info method=POST path="/parse/functions/sendPush" host=xxxx.herokuapp.com request_id=REQUEST_ID fwd="IP_ADDRESS" dyno=web.1 connect=2ms service=132ms status=200 bytes=469
2016-03-03T12:46:07.611072+00:00 app[web.1]: #### PUSH OK
2016-03-03T12:46:07.613190+00:00 app[web.1]: APNS Connection 0 Notification transmitted to DEVICE TOKEN
2016-03-03T12:46:07.613382+00:00 app[web.1]: Can not find sender for push type android, {"where":{"user":{"__type":"Pointer","className":"_User","objectId":"XXXX"}},"data":{"data":{"alert":"sender sent you a friend request!","content-available":1,"badge":10}}}

Hope someone will find a fix for this!

@flovilmart
Copy link
Contributor

It seems that you didn't configure correctly the android key in the push configuration

@Copyrightsworld
Copy link
Author

@fraxool I did have the same issue. What was happening in my case was that the code was pushing to the wrong channel. When i corrected that, everything looks like working now. (im testing on iOS only atm.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question Support or code-level question
Projects
None yet
Development

No branches or pull requests

4 participants