internal static ToastPush ParsePushData(String args) { try { args = System.Net.WebUtility.UrlDecode(args); args = args.Replace("/PushSDK;component/Controls/PushPage.xaml?", ""); JObject jRoot = JObject.Parse(args); ToastPush toast = new ToastPush(); if (jRoot["pushwoosh"] == null) { return(toast); } jRoot = (JObject)jRoot["pushwoosh"]; if (jRoot["content"] != null) { toast.Content = jRoot["content"].ToString(); } if (jRoot["p"] != null) { toast.Hash = jRoot["p"].ToString(); } if (jRoot["h"] != null) { toast.HtmlId = jRoot["h"].ToObject <int>(); } if (jRoot["data"] != null) { toast.UserData = jRoot["data"].ToString(); } try { if (jRoot["l"] != null) { toast.Url = new Uri(jRoot["l"].ToString(), UriKind.Absolute); } } catch { } return(toast); } catch { } return(null); }
internal static ToastPush ParsePushData(String args) { try { args = System.Net.WebUtility.UrlDecode(args); args = args.Replace("/PushSDK;component/Controls/PushPage.xaml?", ""); JObject jRoot = JObject.Parse(args); ToastPush toast = new ToastPush(); if (jRoot["pushwoosh"] == null) return toast; jRoot = (JObject)jRoot["pushwoosh"]; if (jRoot["content"] != null) toast.Content = jRoot["content"].ToString(); if (jRoot["p"] != null) toast.Hash = jRoot["p"].ToString(); if (jRoot["h"] != null) toast.HtmlId = jRoot["h"].ToObject<int>(); if (jRoot["data"] != null) toast.UserData = jRoot["data"].ToString(); try { if (jRoot["l"] != null) toast.Url = new Uri(jRoot["l"].ToString(), UriKind.Absolute); } catch { } return toast; } catch { } return null; }
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(); }); }
private void PushAccepted(ToastPush push) { string pushString = JsonConvert.SerializeObject(push); if (OnPushAccepted != null) OnPushAccepted(this, pushString); }
internal void FireAcceptedPush(ToastPush push) { Statistic.SendPushOpen(push.Hash); if (push.Url != null || push.HtmlId != -1) { WebBrowserTask webBrowserTask = new WebBrowserTask(); if (push.Url != null) webBrowserTask.Uri = push.Url; else if (push.HtmlId != -1) webBrowserTask.Uri = new Uri(Constants.HtmlPageUrl + push.HtmlId, UriKind.Absolute); webBrowserTask.Show(); } PushAccepted(push); }
void service_OnPushAccepted(object sender, ToastPush push) { string pushString = JsonConvert.SerializeObject(push); var alert = new MessageDialog("Notification content: " + pushString + " received"); alert.ShowAsync(); }