public APNSNotification(APNSMessage message, bool priority) { Dictionary <string, Object> aps = new Dictionary <string, Object>(); aps.Add("aps", message.getDictionary()); string json = JsonConvert.SerializeObject(aps); messageSize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Convert.ToInt16(json.Length))); messageData = Encoding.UTF8.GetBytes(json); if (priority) { priorityData = new byte[1] { 0x10 }; } else { priorityData = new byte[1] { 0x05 }; } // ID + Token Size + Token + Message ID + Message Size + Message Data Length int commandSize = 1 + 2 + 32 + 1 + messageSize.Length + messageData.Length; commandBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(commandSize)); }
public APNSNotification(APNSMessage message, bool priority) { Dictionary<string, Object> aps = new Dictionary<string, Object>(); aps.Add("aps", message.getDictionary()); string json = JsonConvert.SerializeObject(aps); messageSize = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(Convert.ToInt16(json.Length))); messageData = Encoding.UTF8.GetBytes(json); if (priority) { priorityData = new byte[1] { 0x10 }; } else { priorityData = new byte[1] { 0x05 }; } // ID + Token Size + Token + Message ID + Message Size + Message Data Length int commandSize = 1 + 2 + 32 + 1 + messageSize.Length + messageData.Length; commandBytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(commandSize)); }