private async void OnAction(IDictionary <string, string> data) { JObject push = pushHistory.Find(item => ((string)item["notification_id"]).Equals(data["notification_id"])); switch (data["action"]) { case "reply": string message = data["message"]; if (data["notification_id"].Contains("sms_")) { //TODO: implement SMS sending throw new NotImplementedException("Not implemented SMS send"); } else { PushbulletUtils.QuickReply(push, message); } break; case "activate": try { string packageName = (string)push["package_name"]; string url = await PushbulletUtils.ResolveUrlFromPackageName(packageName); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(url)); } catch { } break; case "dismiss": default: break; } pushHistory?.RemoveAll(item => ((string)item["notification_id"]).Equals(data["notification_id"])); }
private async void OnData(JObject payload) { string check = (string)payload["type"]; if (check.Equals("push")) { JObject push = (JObject)payload["push"]; pushHistory.Add(push); string type = (string)push["type"]; string id = (string)push["notification_id"]; if (type.Equals("mirror")) { NotificationUtils.ToastFactory factory = new NotificationUtils.ToastFactory() { Id = id, Label = (string)push["title"], Body = (string)push["body"], Image = PushbulletUtils.ConvertBase64Image((string)push["icon"]), AppName = (string)push["application_name"] }; if (push["actions"] != null) { factory.AddActions((JArray)push["actions"]); } if (push["conversation_iden"] != null) { factory.AddReply(); } notification.ShowNotification(factory); } else if (type.Equals("dismissal")) { pushHistory?.RemoveAll(item => ((string)push["notification_id"]).Equals(id)); notification.DismissNotification(id); } else if (type.Equals("sms_changed")) { // TODO: check if SMS is working if (push["notifications"] != null) { foreach (JObject sms in ((JArray)push["notifications"])) { NotificationUtils.ToastFactory factory = new NotificationUtils.ToastFactory() { Id = "sms_" + push["source_device_iden"] + "|" + sms["thread_id"] + "|" + sms["timestamp"], Label = (string)sms["title"], Body = (string)sms["body"], Image = await PushbulletUtils.DownloadImage((string)sms["image_url"]), }; factory.AddReply(); notification.ShowNotification(factory); } } } } }