Skip to content

Instantly share code, notes, and snippets.

@tophyr
Created July 30, 2012 21:40
Show Gist options
  • Save tophyr/3210496 to your computer and use it in GitHub Desktop.
Save tophyr/3210496 to your computer and use it in GitHub Desktop.
switch (row.Platform)
{
case "iOS":
if ((row.DeviceId.Length & 1) != 0)
continue; // deviceid is odd length; what sorcery is this hex that has half a byte?
string payload = String.Format("{{'aps':{{'alert':'This is a push notification'}},'envId':'{0}'}}", envId);
BinaryWriter bw = new BinaryWriter(PushConnection);
bw.Write((byte)0);
bw.Write((byte)(row.DeviceId.Length >> 8));
bw.Write((byte)row.DeviceId.Length);
bw.Write(HexStringToByteArray(row.DeviceId));
bw.Write((byte)(payload.Length >> 8));
bw.Write((byte)payload.Length);
bw.Write(payload.ToCharArray(), 0, payload.Length);
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment