private void btSendToastToWP_Click(object sender, RoutedEventArgs e) { try { PushManager.PushConnect.CheckSetup(); } catch (InvalidSetupException ex) { tbConnectErrors.Text = String.Format("{0}: {1}", ex.Connect.GetType().Name, ex.Message); return; } var lData = new { IsTextSelected = grText.IsChecked.GetValueOrDefault(false), IsBadgeSelected = grBadge.IsChecked.GetValueOrDefault(false), IsSoundSelected = grSound.IsChecked.GetValueOrDefault(false), IsSyncSelected = grSync.IsChecked.GetValueOrDefault(false), IsCommonSelected = grCommon.IsChecked.GetValueOrDefault(false), Title = String.Empty, Text = tbText.Text, SoundFile = tbSound.Text, ImageFile = tbImage.Text, Badge = Convert.ToInt32(tbBadge.Text), }; Task.Factory.StartNew(() => { if (lData.IsCommonSelected) { foreach (var device in PushManager.DeviceManager.Devices) { if (device is WindowsPhonePushDeviceInfo) { var lMessage = new MPNSToastMessage(); lMessage.OSVersion = MPNSDeviceVersion.Seven; lMessage.NotificationURI = (device as WindowsPhonePushDeviceInfo).NotificationURI.ToString(); lMessage.Text1 = lData.Title + " (" + lData.Badge + ")"; lMessage.Text2 = lData.Text; PushManager.PushConnect.MPNSConnect.PushMessage(lMessage); } } } }); }
private void PushConnectOnMessageCreating(object aSender, MessageCreateEventArgs anArgs) { var lDevice = anArgs.Device as WindowsPhonePushDeviceInfo; if (lDevice != null) { var lMessage = new MPNSToastMessage(); lMessage.Text1 = anArgs.MessageData.Title; lMessage.Text2 = anArgs.MessageData.Text; lMessage.NotificationURI = lDevice.NotificationURI.ToString(); anArgs.Message = lMessage; } }