Created
July 30, 2012 21:40
-
-
Save tophyr/3210496 to your computer and use it in GitHub Desktop.
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
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