private void ChannelShellToastNotificationReceived(object sender, NotificationEventArgs e) { Debug.WriteLine("/********************************************************/"); Debug.WriteLine("Received Toast: " + DateTime.Now.ToShortTimeString()); foreach (string key in e.Collection.Keys) { Debug.WriteLine("{0}: {1}", key, e.Collection[key]); if (key == "wp:Param") { LastPush = SDKHelpers.ParsePushData(e.Collection[key]); } } Debug.WriteLine("/********************************************************/"); Deployment.Current.Dispatcher.BeginInvoke(() => { var message = new PushNotificationMessage(e.Collection); message.Completed += (o, args) => { if (args.PopUpResult == PopUpResult.Ok) { FireAcceptedPush(); } }; message.Show(); }); }
static public void HandleStartPush(string arguments) { if (arguments != null && arguments.Length != 0) { try { //Sample to handle push custom data on start ToastPush push = SDKHelpers.ParsePushData(arguments); if (push != null) { push.OnStart = true; NotificationService.StartPush = push; NotificationService service = NotificationService.GetCurrent(null); if (service != null) { StatisticRequest request = new StatisticRequest { AppId = service.AppID, Hash = push.Hash }; PushwooshAPIServiceBase.InternalSendRequestAsync(request, null, null); } } } catch { } } }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); var applicationService = ((PhonePushApplicationService)PhoneApplicationService.Current); applicationService.NotificationService.LastPush = SDKHelpers.ParsePushData(e.Uri.ToString()); applicationService.NotificationService.FireAcceptedPush(); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); ToastPush push = SDKHelpers.ParsePushData(e.Uri.ToString()); push.OnStart = true; NotificationService instance = NotificationService.GetCurrent(); if (instance != null) { instance.FireAcceptedPush(push); } else { NotificationService.StartPush = push; } string startPage = "/" + WMAppManifestReader.GetInstance().NavigationPage; ((PhoneApplicationFrame)Application.Current.RootVisual).Navigate(new Uri(startPage, UriKind.RelativeOrAbsolute)); }
private void ChannelShellToastNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs e) { Debug.WriteLine("/********************************************************/"); Debug.WriteLine("Incoming Notification: " + DateTime.Now.ToString()); String notificationContent = String.Empty; ToastPush push = null; String type = String.Empty; switch (e.NotificationType) { case PushNotificationType.Badge: notificationContent = e.BadgeNotification.Content.GetXml(); type = "Badge"; break; case PushNotificationType.Tile: notificationContent = e.TileNotification.Content.GetXml(); type = "Tile"; break; case PushNotificationType.Toast: notificationContent = e.ToastNotification.Content.GetXml(); try { IXmlNode node = e.ToastNotification.Content.DocumentElement.SelectSingleNode("/toast"); IXmlNode launchAttr = node.Attributes.GetNamedItem("launch"); String args = launchAttr.NodeValue.ToString(); push = SDKHelpers.ParsePushData(args); //Sample to handle push custom data on start StatisticRequest request2 = new StatisticRequest { AppId = AppID, Hash = push.Hash }; PushwooshAPIServiceBase.InternalSendRequestAsync(request2, null, null); } catch { } type = "Toast"; break; case PushNotificationType.Raw: notificationContent = e.RawNotification.Content; type = "Raw"; break; } if (push == null) { StatisticRequest request2 = new StatisticRequest { AppId = AppID }; PushwooshAPIServiceBase.InternalSendRequestAsync(request2, null, null); } Debug.WriteLine("Received {0} notification", type); Debug.WriteLine("Notification content: " + notificationContent); CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { try { if (push != null) { FireAcceptedPush(push); } } catch (Exception) { //Noting todo here } }); }