Urban Airship Tags issue

I modified the alias sample code from:

    [request addRequestHeader: @"Content-Type" value: @"application/json"];
    [request appendPostData:[[NSString stringWithFormat: @"{\"alias\": \"%@\"}", self.deviceAlias]
                          dataUsingEncoding:NSUTF8StringEncoding]];

to:

[request addRequestHeader: @"Content-Type" value: @"application/json"];
[request appendPostData:[[NSString stringWithFormat: @"{\"tags\": \"%@\"}", offsetStr]
                                                 dataUsingEncoding:NSUTF8StringEncoding]];

offsetStr is a string containing a Timezone offset (which can be any number between -12 and 12).

For some reason, Urban Airship is making each character of the string into its own tag.

I've tried to substitute the - for a string neg with the same results.

What's wrong?

Answers


The problem is that "tags" should be a list, not a single value. Through square brackets around the value, and you'll be fine.

[request addRequestHeader: @"Content-Type" value: @"application/json"];
[request appendPostData:[[NSString stringWithFormat: @"{\"tags\": [\"%@\]"}", offsetStr]
                                             dataUsingEncoding:NSUTF8StringEncoding]];

But you really should use a JSON library, like json-framework or TouchJSON if you want to encode JSON on the client.


Need Your Help

Application servers tab not enabled in Intellij ultimate edition

java eclipse tomcat intellij-idea application-server

So, after several years using Eclipse I finally decided to give IntelliJ a chance (ultimate edition).

Swipebox - Loading HTML instead of images

javascript jquery html lightbox

I chose Swipebox as my lightbox because the requirements that I want is that it is swipable in mobile devices ad is responsive.