nomad-cli / houston

Apple Push Notifications; No Dirigible Required
http://nomad-cli.com
MIT License
2.93k stars 229 forks source link

Number in a payload delivered as NSString #86

Closed borkasm closed 9 years ago

borkasm commented 9 years ago

When I send a notification like this

apn push fcc3551cd74e40d45beb109946a6ca6dc7423e16dd042e2b2aa06f07183d5b8c -c apns-dev-cert.pem -m "Credits" -d credits=100

payload's credits: value is delivered as instance of NSString but not a NSNumber

mattt commented 9 years ago

Command line input is all interpreted as a string. Unfortunately, there is no way to coerce other types from the CLI. To send numbers as integers or floating points, you must send a JSON payload from the scripting interface.

borkasm commented 9 years ago

Ok, then there's a mistake in this article. Sample code under the "Sending Remote Notifications" section assumes that there will be an NSNumber.

mattt commented 9 years ago

Alright, you should raise that with the @objcio folks.

jayesh15111988 commented 8 years ago

@intrigua How did you manage to send a JSON payload with push notifications? I am trying to send standard json as a payload from command line, but getting an exception parsing a JSON. @mattt Any help would be much appreciate.

jdraths commented 8 years ago

@jayesh15111988 why not just convert the JSON payload to NSNumber or Int on the client and not worry about whether the JSON payload represents the number as a string or integer?

jayesh15111988 commented 8 years ago

@jdraths My question was not about data type of JSON payload integer vs string. I was just curious to find out how to send JSON data as push payload through Houston.

jdraths commented 8 years ago

@jayesh15111988 use -P to send a json payload per this code.

$ apn push "<token>" -c /path/to/apple_push_notification.pem -m "Hello from the command line! " -P {"your_json": "value", "more_json": "more values", "integer": 1} Not sure if my format is right but it's close.