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 does not work as written in tutorial for Windows #487

Open
Lukenickerson opened this issue May 8, 2017 · 5 comments
Open

Push does not work as written in tutorial for Windows #487

Lukenickerson opened this issue May 8, 2017 · 5 comments
Assignees

Comments

@Lukenickerson
Copy link

Following along the instructions on http://docs.phonegap.com/develop/push-notifications/ with the default push example that is included with the Windows Phonegap app gives an error on the first "Sending Your First Push" step. I've found that doing phonegap push --deviceID [whatever device id] --service gcm --payload '{ "data": { "title": "Hello", "message": "World"} }' (with the appropriate device id entered) gives this error when using PowerShell:

SyntaxError: Unexpected token d in JSON at position 2
at Object.parse (native)
at PushCommand.execute
at PushCommand.run
at PhoneGap.push
at CLI.module.exports [as push]
at CLI.module.exports [as argv]
at runPhoneGapCommand
at Object.
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)

And a similar, but different, error when using the vanilla command prompt:

SyntaxError: Unexpected token ' in JSON at position 0

System: Windows 10, using Phonegap 6.4.3

Expected: Instructions would say that they are incompatible with Windows, or provide alternative command line instructions.

@racingsolution
Copy link

Try this

phonegap push --deviceID [whatever device id] --service gcm --payload '{ "data": { "title": "Hello", "message": "World"} }'

@racingsolution
Copy link

Well that didn't work. Add a backslash before each double quote

@Lukenickerson
Copy link
Author

Thanks @racingsolution .

Outer single quotes and escaped double-quotes worked in PowerShell:
phonegap push --deviceID [the long device id] --service gcm --payload '{ \"data\": { \"title\": \"Hello\", \"message\": \"World\"} }'

...whereas outer double-quotes was necessary in the Windows command prompt:
phonegap push --deviceID [the long device id] --service gcm --payload "{ \"data\": { \"title\": \"Hello\", \"message\": \"World\"} }"

I would recommend that these instructions be included in the docs.phonegap.com documentation.

@macdonst macdonst self-assigned this May 15, 2017
@macdonst
Copy link
Member

@Lukenickerson thanks for pointing this out. I will update the docs. I've added Windows command line instructions in my push workshops but I forgot to update docs.phonegap.com.

@LV8or
Copy link

LV8or commented Jun 23, 2017

I have tried to run this on Windows to test on my phone (Galaxy S7) and in Chrome. When I use my phone device id it returns back with body: OK, but I do not get a message. When I put in my browser device id, the terminal freezes. Is there anything else I should be doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants