Sending iOS Specific push parameters error

curl -X POST -u "<app_key>:<master_secret>" -H "Content-Type: application/json" -H "Accept: application/vnd.urbanairship+json; version=3;" \
--data '{"audience": {"ios_channel": "channel id"}, "notification": {"alert": "Hello!", "badge": "+1"}, "device_types": ["ios"]}'


If I try above curl command, it will return an error:

{"ok":false,"error":"Could not parse request body.","error_code":40000,"details":{"error":"The key 'badge' is not allowed in this context","path":"notification.badge","location":{"line":1,"column":117}},"operation_id":""}


However if I remove badge parameter, the request can go through. This has same result if I try to add "sound" parameter.

Didn't find what you were looking for?

New post



  • Hi Bill,

    This is Sean with Urban Airship Technical Support.

    Platform specific options, such as badge or sound options for iOS, need to be in a platform override object within the notification object. You can find more information in our API Reference Documentation.

    Below is an edit of your payload as an example of a valid payload with badging data.

      "audience": {
        "ios_channel": "channel id"
      "notification": {
          "ios": {
             "alert": "Hello!"
             "badge": "+1"
      "device_types": [


    Thank you,
    Sean Conlin
    Urban Airship Technical Support
    Portland, Oregon

    Comment actions Permalink
  • Thanks. Actually I was following ruby server side guide and it didn't put iOS specific parameter in a platform override object, so it confused me.

    The docs showed (in attachment):

    push.notification = UA.ios(
        alert: 'hello world',
        badge: 123,
        sound: 'sound file',
        extra: { 'key' => 'value', 'key2' => 'value2' }
        expiry: '2012-01-01 12:45',
        category: 'category_name',
        interactive: UA.interactive(
            type: 'ua_share',
            button_actions: {
                share: { share: 'Sharing is caring!' }
        content_available: true


    Which should be:

    push.notification = UA.notification(
    ios: UA.ios(
    alert: 'hello world', badge: 123, sound: 'sound file'


    Although it has correct example at the end of documentation, it'd be better to make it consistency in case of confusion in the future.

    Comment actions Permalink
  • 0
  • Hi Bill,

    The UA.ios class will set the iOS object for you.
    To clarify, I don't believe the server-side libraries were designed to have their syntax be a 1 to 1 map of the push payload, and the ruby server library has a different class for each platform.


    Comment actions Permalink
  • I didn't look into how the library was written. All I know is if I use UA.ios directly it won't work for me.

    Also the sample code for sending single iOS notification put UA.ios inside UA.notification as well:

    Comment actions Permalink
  • Ah, I see what you're saying.

    I'll get that documentation cleaned up. Thanks for pointing that out.

    Comment actions Permalink

Please sign in to leave a comment.