コード例 #1
0
ファイル: APNSNotification.cs プロジェクト: thewruck/bvcms
        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));
        }
コード例 #2
0
ファイル: APNSNotification.cs プロジェクト: stevesloka/bvcms
		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));
		}
コード例 #3
0
ファイル: APNSHelper.cs プロジェクト: stevesloka/bvcms
        public static void sendNotification(List<MobileAppPushRegistration> registrations, string title, string content)
        {
            APNSConnection connection = new APNSConnection();
            connection.open();

            APNSAlert alert = new APNSAlert("New Notification", "You have a notification!");

            APNSMessage message = new APNSMessage();
            message.addAlert(alert);
            message.addSound("default");
            message.addCommand(3);

            APNSNotification notification = new APNSNotification(message, true);

            foreach (MobileAppPushRegistration registration in registrations)
            {
                notification.setDeviceToken(registration.RegistrationId);
                notification.sendViaConnection(connection);
            }

            connection.close();
        }
コード例 #4
0
ファイル: APNSHelper.cs プロジェクト: thewruck/bvcms
        public static void sendNotification(List <MobileAppPushRegistration> registrations, string title, string content)
        {
            APNSConnection connection = new APNSConnection();

            connection.open();

            APNSAlert alert = new APNSAlert("New Notification", "You have a notification!");

            APNSMessage message = new APNSMessage();

            message.addAlert(alert);
            message.addSound("default");
            message.addCommand(3);

            APNSNotification notification = new APNSNotification(message, true);

            foreach (MobileAppPushRegistration registration in registrations)
            {
                notification.setDeviceToken(registration.RegistrationId);
                notification.sendViaConnection(connection);
            }

            connection.close();
        }