Created
May 21, 2012 02:49
-
-
Save MikeLarned/2760371 to your computer and use it in GitHub Desktop.
UrbanAirshipMessageAliases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Authorization: Basic <key:secret> | |
| Content-Type: application/json | |
| Host: go.urbanairship.com | |
| Content-Length: 243 | |
| POST - https://go.urbanairship.com/api/push/ | |
| Request Body: | |
| { | |
| "aliases" : ["MikePhone"], | |
| "tags" : [""], | |
| "android" : { | |
| "alert" : "Messaging", | |
| "extra" : { | |
| "url" : "http://www.google.com" | |
| } | |
| }, | |
| "aps" : { | |
| "alert" : "Messaging", | |
| "url" : "http://www.google.com" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void MessageAliases(string message, Dictionary<string, string> extras, IEnumerable<string> aliases) | |
| { | |
| var push = GetPushMessage(message, extras, aliases: aliases); | |
| Http.Post(GetApiUrl("push/"), WithMasterSecret, push); | |
| } | |
| private object GetPushMessage(string message, Dictionary<string, string> extras, IEnumerable<string> tags = null, IEnumerable<string> aliases = null) | |
| { | |
| var iosPush = new Dictionary<string, object> { { "alert", message } }; | |
| foreach (var kvp in extras) | |
| { | |
| iosPush.Add(kvp.Key, kvp.Value); | |
| } | |
| var androidBroadcast = new { alert = message , extra = extras }; | |
| if(tags != null && aliases != null) | |
| return new { aliases, tags, android = androidBroadcast, aps = iosPush }; | |
| if(tags == null) | |
| return new { aliases, android = androidBroadcast, aps = iosPush }; | |
| return new { tags, android = androidBroadcast, aps = iosPush }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment