Closed borkasm closed 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.
Ok, then there's a mistake in this article. Sample code under the "Sending Remote Notifications" section assumes that there will be an NSNumber.
Alright, you should raise that with the @objcio folks.
@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.
@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?
@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.
@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.
When I send a notification like this
payload's
credits:
value is delivered as instance of NSString but not a NSNumber