Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Number in a payload delivered as NSString #86

Closed
borkasm opened this issue Dec 18, 2014 · 7 comments
Closed

Number in a payload delivered as NSString #86

borkasm opened this issue Dec 18, 2014 · 7 comments

Comments

@borkasm
Copy link

borkasm commented Dec 18, 2014

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
Copy link
Contributor

mattt commented Dec 18, 2014

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.

@mattt mattt closed this as completed Dec 18, 2014
@borkasm
Copy link
Author

borkasm commented Dec 19, 2014

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
Copy link
Contributor

mattt commented Dec 19, 2014

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

@jayesh15111988
Copy link

@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
Copy link

jdraths commented Jun 17, 2016

@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
Copy link

@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
Copy link

jdraths commented Jun 17, 2016

@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.

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

No branches or pull requests

4 participants