/api/push not working with multiple tags

Hi All

Just wanted to raise what recently caught me out. It could be a bug in api or error in api documentation but since I'm not on a paid level of platform I cant raise a ticket.

Issue is to do with sending a push notification. According to the info at https://docs.urbanairship.com/api/ua/#push-object, you can send an array of tags

            "tag": [
               "sports",
               "entertainment"
            ]

 

In my case I was only wanting to notify devices with a single tag so the array only had one item but it was still an array with a single string containing a valid tag. The api call accepts my call and responds with a 202 but no notifications ever arrived and if I queried the push_id I could see that no messages were sent. If I made the same call but used a single tag sent as a string instead of a string inside an array then the API responds with 202 and the notification is sent.

Is the api doc wrong?
Is the api got a bug?

Or have I misread something? ;)

 

Didn't find what you were looking for?

New post

Comments

8 comments

  • Hi Mark,

    Do you happen to have your device ID and the push IDs for the notifications on hand? I'd also be interested in seeing the payload for your request so I can try to reproduce this behavior on my end.

    Thank you!

    Comment actions Permalink
    0
  • Hi Jennifer

    Appreciate you getting in touch. Just reproduced and details are below

    Thanks

    Mark

    named_user_id "SIM-1498010159-8-dev-nibbl"

    push_address "A04A9FB2AE0FDE0BBFEEC13F5B298D78381076B3F01810876CCE329D8DD7997A"


    Working push_id "f7743cb5-b3ca-416c-aca4-026901d9470e"

    Working payload

    {

      "audience": {
        "tag": "chem-alert", "group": "aws"
      },
      "notification": {
        "alert": "chem-alert"
      },
        "device_types": "all"
    }

    Failing push_id "d1daa506-ffe6-45c1-8ab0-447ab624e301"

    Failing payload

    {
      "audience": {
        "tag": ["chem-alert"], "group": "aws"
      },
      "notification": {
        "alert": "chem-alert"
      },
        "device_types": "all"
    }

    Comment actions Permalink
    0
  • Hi Jennifer

    Any update on this behaviour?

     

    Thanks

    Comment actions Permalink
    0
  • Jennifer

    Now I notice that API docs specify you can target a named user in the audience as per instructions found at https://docs.urbanairship.com/api/ua/#push-object

     

    And a Named User:

    {
       "audience" : {
          "named_user" : "user-id-54320"
       }
    }

     

    Yet when I send a call using the below JSON body to https://go.urbanairship.com/api/push

    {
      "audience": {
        "named_user": "SIM-1498010159-8-dev-nibbl"
      },
      "notification": {
         "alert": "chem-alert"
      },
      "device_types": "all"
    }

    We get the following response

    {
      "ok": false,
      "error": "Could not parse request body.",
      "error_code": 40540,
      "details": {
      "error": "The feature 'named_user' is not supported on the 'mpns' platform"
      }
    }

    Am I just doing something really really dumb? I'm beginning to lose all faith in this platform unless we can figure it out quickly.

    I appreciate that we are on free version while we evaluate but so far I cant say I'm exactly impressed so we may need to move to another platform soon

    Comment actions Permalink
    0
  • Hi Mark,
     
    Apologies for the late response on this.
     
    In regards to the first issue you detailed, including brackets in the audience section will only result in a successful push if you are sending a notification to an array of tags. If you are targeting a single tag, quotation marks must be specified instead. 
     
    The named user feature isn’t supported by our MPNS platform, so “all” for the audience cannot be specified. You must instead target the individual platforms that support it (i.e."device_types": [“ios”, “android”]). The request should go through once you change that. 
    Comment actions Permalink
    0
  • Hi Jennifer 

    Thanks for getting back in touch. A bit frustrating that the API doc doesn't quite specify the requirement. Maybe it does but its not prominent but thats fine. Now I know ;)

    So yesterday I tested a few push notifications via Postman using a single tag and it worked OK. Today its failing

    Below is payload

    {
    "audience": {
    "tag": "chem-alert", "group": "aws"
    },
    "notification": {
    "alert": "chem-alert"
    },
    "device_types": ["ios"]
    }

    Response

    {
    "ok": true,
    "operation_id": "f7b9b8d3-976f-4ae2-a839-0849fa60345c",
    "push_ids": [
    "d0f31249-3830-400a-9126-d174f77e3a03"
    ],
    "message_ids": [],
    "content_urls": []
    }

    However no notification arrives and when I query the push ID the sends: value is 0
    I queried the named user and the tag exists and the device is ios. Using "all" fails regardless

     

    {
    "ok": true,
    "named_user": {
    "named_user_id": "SIM-1498010159-8-dev-nibbl",
    "tags": {
    "aws": [
    "chem-alert"
    ]
    },
    "created": "2017-09-10T23:55:56",
    "last_modified": "2017-09-25T19:48:08",
    "channels": []
    }
    }

    Appreciate any assistance in resolving this so we can move onwards with more features on the platform

    Mark

    Comment actions Permalink
    0
  • Hi Mark,
     
    I do agree that the API documentation could be clearer for that. I’ll go ahead and put in a ticket to our Docs team to specify that brackets must be used when targeting an array of tags and that quotation marks must be used when targeting a single tag. 
     
    I looked up the named user 'SIM-1498010159-8-dev-nibbl’ on both the nibbl-dev app and the nibbl-prod app via the UI and the API. It looks like no devices are associated to this named user. 
    {
        "ok": true,
        "named_user": {
            "named_user_id": "SIM-1498010159-8-dev-nibbl",
            "tags": {
                "aws": [
                    "chem-alert",
                    "chem_alert"
                ]
            },
            "created": "2017-09-10T23:55:56",
            "last_modified": "2017-09-25T20:48:35",
            "channels": []
        }
    }
     
    It also looks like none of your devices have the 'chem-alert' added to it, although it sounds like this was working previously. How are you adding tags to your devices? 
    Comment actions Permalink
    0
  • Ahh

    I see whats happened here. Our app can flick between dev and test for testing purposes and we can also pair it with multiple h/w devices which is when we associate the named_user. The app had not been re-paired correctly

    Absolutely my bad on that one sorry

    Tags are added via API using https://go.urbanairship.com/api/named_users/tags anbd we send an array of users and the tags we want added. the _ and - is just us testing 

    I'll now begin to test the actual live code in AWS to see how we get on

    Really appreciate your help

    Comment actions Permalink
    0

Please sign in to leave a comment.