Skip to content

Instantly share code, notes, and snippets.

@MikeLarned
Created May 21, 2012 02:49
Show Gist options
  • Select an option

  • Save MikeLarned/2760371 to your computer and use it in GitHub Desktop.

Select an option

Save MikeLarned/2760371 to your computer and use it in GitHub Desktop.
UrbanAirshipMessageAliases
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"
}
}
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