public async void Run(IBackgroundTaskInstance taskInstance) { // simple example with a Toast, to enable this go to manifest file // and mark App as TastCapable - it won't work without this // The Task will start but there will be no Toast. //ToastTemplateType toastTemplate = ToastTemplateType.ToastText02; //XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); //XmlNodeList textElements = toastXml.GetElementsByTagName("text"); //textElements[0].AppendChild(toastXml.CreateTextNode("My first Task - Yeah")); //textElements[1].AppendChild(toastXml.CreateTextNode("I'm a message from your background task!")); //ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml)); var deferral = taskInstance.GetDeferral(); RawNotification raw = taskInstance.TriggerDetails as RawNotification; if (raw != null) { Debug.WriteLine( string.Format("XXXXXXXXXXXXXReceived from cloud:XXXXXXXXXX [{0}]", raw.Content)); } deferral.Complete(); }
public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; _deferral = taskInstance.GetDeferral(); var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; XDocument xdoc = XDocument.Parse(notification.Content); string task = xdoc.Root.Element("Task").Value; if (task.Equals("ShowInfoMessage")) { string mid = xdoc.Root.Element("MessageID").Value; string title = xdoc.Root.Element("Title").Value; string content = xdoc.Root.Element("Content").Value; var last_mid = localSettings.Values["ToastMessageID"]; if (last_mid != null && last_mid.Equals(mid)) { return; } localSettings.Values["ToastMessageID"] = mid; showInfoMessage(title, content); } }
public void Run(IBackgroundTaskInstance taskInstance) { BackgroundTaskDeferral _deferral = taskInstance.GetDeferral(); // Get the background task details ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; string taskName = taskInstance.Task.Name; Debug.WriteLine("Background " + taskName + " starting..."); taskInstance.Canceled += TaskInstanceCanceled; // Store the content received from the notification so it can be retrieved from the UI. RawNotification notification = (RawNotification)taskInstance.TriggerDetails; ApplicationDataContainer container = ApplicationData.Current.LocalSettings; container.Values["RawMessage"] = notification.Content.ToString(); //SendToastNotification(notification.Content); Debug.WriteLine("Background " + taskName + " completed!"); _deferral.Complete(); }
public void handleRawNotification(RawNotification notification) { XmlDocument doc = new XmlDocument(); doc.LoadXml(notification.Content); XmlNodeList groupXml = doc.GetElementsByTagName("Group"); XmlNodeList msgXml = doc.GetElementsByTagName("Message"); XmlNodeList actionXml = doc.GetElementsByTagName("Action"); if (groupXml.Any() && msgXml.Any()) { string groupId = groupXml[0].InnerText; string msgId = msgXml[0].InnerText; if (group.group.id == groupId) { if (actionXml.Any() && actionXml[0].InnerText == "newAttachment") { History.addMsgFile(msgId); } else { History.retrieveNewMessages(); } } } }
public void Run(IBackgroundTaskInstance taskInstance) { // 受信したRaw Notification RawNotification notification = (RawNotification)taskInstance.TriggerDetails; // トーストのテンプレートを選択 ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); // トーストに表示するテキストを指定 XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text"); toastTextElements[0].AppendChild(toastXml.CreateTextNode("What's New")); // トーストに表示する画像を指定 XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image"); ((XmlElement)toastImageAttributes[0]).SetAttribute("src", "https://2.bp.blogspot.com/-Euo8ySieZ1s/VlAYy90a2oI/AAAAAAAA02Y/r3AmTznIjOo/s800/allergy_kuri.png"); // トーストをクリックした場合、パラメータ付きでアプリを起動する IXmlNode toastNode = toastXml.SelectSingleNode("/toast"); ((XmlElement)toastNode).SetAttribute("launch", notification.Content); // トースト表示 ToastNotification toast = new ToastNotification(toastXml); ToastNotificationManager.CreateToastNotifier().Show(toast); }
protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) { RawNotification notification = (RawNotification)args.TaskInstance.TriggerDetails; var deferral = args.TaskInstance.GetDeferral(); base.OnBackgroundActivated(args); ToastContent content = new ToastContent() { Launch = "blah", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "It worked!!!" } } } } }; ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); await Task.Delay(5000); deferral.Complete(); }
public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; string content = notification.Content; throw new NotImplementedException(); }
public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; string content = notification.Content; System.Diagnostics.Debug.WriteLine(content); await testLoop(); _deferral.Complete(); }
private void WNS_PushNotificationReceived(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { if (args.NotificationType == PushNotificationType.Raw) { RawNotification notification = args.RawNotification; ToastHelper.showSimpleToast(notification.Content); } }
private void WriteRawOptions(JsonWriter writer, RawNotification option) { writer .StartObject() .WriteProperty("notificationtype", "raw") .WriteProperty("data", option.RawData, true) .EndObject(); }
/// <summary>Initializes a new instance of the <see cref="MarkerNotification"/> class.</summary> /// <param name="rawNotification">The raw notification.</param> internal unsafe MarkerNotification(RawNotification* rawNotification) : base(rawNotification) { CueIndex = rawNotification->Data.Marker.CueIndex; SoundBank = CppObject.FromPointer<SoundBank>(rawNotification->Data.Marker.SoundBankPointer); Cue = CppObject.FromPointer<Cue>(rawNotification->Data.Marker.CuePointer); Marker = rawNotification->Data.Marker.Marker; }
public async void Handle(BackgroundActivatedEventArgs args) { var taskInstance = args.TaskInstance; taskInstance.Canceled += TaskInstance_Canceled; var deferral = taskInstance.GetDeferral(); try { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; long accountId = UWPPushExtension.GetAccountIdFromRawNotification(notification); if (accountId == 0) { return; } AccountDataItem account = await AccountsManager.GetOrLoadOnlineAccount(accountId); if (account == null) { return; } var cancellationToken = _cancellationTokenSource.Token; try { cancellationToken.ThrowIfCancellationRequested(); var result = await Sync.SyncAccountAsync(account); // Need to wait for the tile/toast tasks to finish before we release the deferral if (result != null && result.SaveChangesTask != null) { await result.SaveChangesTask.WaitForAllTasksAsync(); } } catch (OperationCanceledException) { } // Wait for the calendar integration to complete await AppointmentsExtension.Current?.GetTaskForAllCompleted(); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } finally { deferral.Complete(); } }
public void Run(IBackgroundTaskInstance taskInstance) { ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; string taskName = taskInstance.Task.Name; RawNotification notification = (RawNotification)taskInstance.TriggerDetails; settings.Values[taskName] = notification.Content; }
internal unsafe VariableNotification(RawNotification* rawNotification) : base(rawNotification) { CueIndex = rawNotification->Data.Variable.CueIndex; SoundBank = CppObject.FromPointer<SoundBank>(rawNotification->Data.Variable.SoundBankPointer); Cue = CppObject.FromPointer<Cue>(rawNotification->Data.Variable.CuePointer); VariableIndex = rawNotification->Data.Variable.VariableIndex; VariableValue = rawNotification->Data.Variable.VariableValue; IsLocal = rawNotification->Data.Variable.Local; }
internal unsafe WaveNotification(RawNotification* rawNotification) : base(rawNotification) { WaveBank= CppObject.FromPointer<WaveBank>(rawNotification->Data.Wave.WaveBankPointer); WaveIndex = rawNotification->Data.Wave.WaveIndex; CueIndex = rawNotification->Data.Wave.CueIndex; SoundBank = CppObject.FromPointer<SoundBank>(rawNotification->Data.Wave.SoundBankPointer); Cue = CppObject.FromPointer<Cue>(rawNotification->Data.Wave.CuePointer); Wave = CppObject.FromPointer<Wave>(rawNotification->Data.Wave.WavePointer); }
public static async void UpdateToastAndTiles(RawNotification rawNotification) { var payload = (rawNotification != null) ? rawNotification.Content : null; if (payload == null) { return; } var notification = GetRootObject(payload); if (notification == null) { return; } if (notification.data == null) { return; } if (notification.data.loc_key == null) { RemoveToastGroup(GetGroup(notification.data)); return; } var caption = GetCaption(notification.data); var message = GetMessage(notification.data); var sound = GetSound(notification.data); var launch = GetLaunch(notification.data); var tag = GetTag(notification.data); var group = GetGroup(notification.data); if (notification.data.loc_key.Equals("PHONE_CALL_REQUEST")) { AddToast("PHONE_CALL_REQUEST", "PHONE_CALL_REQUEST", null, "launch", null, null, "voip"); await VoipCallCoordinator.GetDefault().ReserveCallResourcesAsync("Unigram.Tasks.VoIPCallTask"); return; } if (!IsMuted(notification.data)) { AddToast(caption, message, sound, launch, notification.data.custom, tag, group); } if (!IsMuted(notification.data) && !IsServiceNotification(notification.data)) { UpdateTile(caption, message); } if (!IsMuted(notification.data)) { UpdateBadge(notification.data.badge); } }
public void Run(IBackgroundTaskInstance taskInstance) { // Get the background task details ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; string taskName = taskInstance.Task.Name; Debug.WriteLine("Background " + taskName + " starting..."); // Store the content received from the notification so it can be retrieved from the UI. RawNotification notification = (RawNotification)taskInstance.TriggerDetails; settings.Values[taskName] = notification.Content; Debug.WriteLine("Background " + taskName + " completed!"); }
public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails as RawNotification; if (notification != null) { ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01; XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate); var textElemets = toastXml.GetElementsByTagName("text"); textElemets[0].AppendChild(toastXml.CreateTextNode(notification.Content)); var imageElement = toastXml.GetElementsByTagName("image"); imageElement[0].Attributes[1].NodeValue = "ms-appx:///Assets/50.png"; ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml)); } }
void OnNotify(ref RawNotification notification) { if (notification.Type == NotificationType.CueStop) { PushDestroyList(notification.Data.Cue.CuePointer); } else if (notification.Type == NotificationType.CueDestroyed) { //var ptr = notification.Data.Cue.CuePointer; //if (m_activeCues.ContainsKey(ptr.ToInt64())) //{ // PushDestroyList(notification.Data.Cue.CuePointer); //} } }
public static void UpdateToastAndTiles(RawNotification rawNotification) { var payload = rawNotification != null ? rawNotification.Content : null; if (payload == null) { return; } var rootObject = GetRootObject(payload); if (rootObject == null) { return; } if (rootObject.data == null) { return; } if (rootObject.data.loc_key == null) { var groupname = GetGroup(rootObject.data); RemoveToastGroup(groupname); return; } var caption = GetCaption(rootObject.data); var message = GetMessage(rootObject.data); var sound = GetSound(rootObject.data); var launch = GetLaunch(rootObject.data); var tag = GetTag(rootObject.data); var group = GetGroup(rootObject.data); if (!IsMuted(rootObject.data)) { AddToast(caption, message, sound, launch, tag, group); } if (!IsMuted(rootObject.data) && !IsServiceNotification(rootObject.data)) { UpdateTile(caption, message); } if (!IsMuted(rootObject.data)) { UpdateBadge(rootObject.data.badge); } }
public static long GetAccountIdFromRawNotification(RawNotification notif) { if (notif == null || notif.Content == null) { return(0); } long accountId; if (long.TryParse(notif.Content, out accountId)) { return(accountId); } else { return(0); } }
public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); // Get the raw notification content RawNotification notification = (RawNotification)taskInstance.TriggerDetails; string content = notification.Content; //// Create sample file; replace if exists. //Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder; //Windows.Storage.StorageFile sampleFile = await storageFolder.CreateFileAsync("sample.txt", // Windows.Storage.CreationCollisionOption.ReplaceExisting); // Display a toast ToastHelper.PopToast("Push Notification received", content); _deferral.Complete(); }
public void Run(IBackgroundTaskInstance taskInstance) { var _deferral = taskInstance.GetDeferral(); // Get the background task details ApplicationDataContainer settings = ApplicationData.Current.LocalSettings; string taskName = taskInstance.Task.Name; Debug.WriteLine("Background " + taskName + " starting..."); // Store the content received from the notification so it can be retrieved from the UI. RawNotification notification = (RawNotification)taskInstance.TriggerDetails; settings.Values[taskName] = notification.Content; // Pop up a toast to notify the user DeliverToast("test", "testid"); Debug.WriteLine("Background " + taskName + " completed!"); }
public void handleRawNotification(RawNotification notification) { XmlDocument doc = new XmlDocument(); doc.LoadXml(notification.Content); XmlNodeList groupXml = doc.GetElementsByTagName("Group"); XmlNodeList msgXml = doc.GetElementsByTagName("Message"); XmlNodeList actionXml = doc.GetElementsByTagName("Action"); if (groupXml.Any() && msgXml.Any()) { string groupId = groupXml[0].InnerText; string action = actionXml[0].InnerText; if (action == "groupUpdate") { retrieveGroupsFromServer(); } } }
/// <summary> /// Gets a RawNotification for a specific channel. /// </summary> /// <param name="sender">PushNotification channel as sender</param> /// <param name="args">Event args</param> /// <returns>Push notofication as RawNotification</returns> public RawNotification GetRawNotification(PushNotificationChannel sender, PushNotificationReceivedEventArgs args) { RawNotification rawNotification = null; if (sender != null && sender == this.NotificationChannel && args != null) { if (args.NotificationType == PushNotificationType.Raw) { rawNotification = args.RawNotification; } else { throw new Exception("The push notification is not a RawNotification type."); } } else { throw new Exception("The push notification channel is invalid."); } return(rawNotification); }
private static async Task <string> GetDecryptedContentHelperAsync(RawNotification notification) { if (notification.Headers == null) { // It's not encrypted return(notification.Content); } string encryptedPayload = notification.Content; // r/JwZaorThJfqkpZjV6umbDXQy9G string cryptoKey = notification.Headers["Crypto-Key"]; // dh=BNSSQjo... string contentEncoding = notification.Headers["Content-Encoding"]; // aesgcm string encryption = notification.Headers["Encryption"]; // salt=WASwg7... var storage = await PushSubscriptionStorage.GetAsync(); StoredPushSubscription[] storedSubscriptions = storage.GetSubscriptions(notification.ChannelId); foreach (var sub in storedSubscriptions) { try { byte[] userPrivateKey = WebEncoder.Base64UrlDecode(sub.P265Private); byte[] userPublicKey = WebEncoder.Base64UrlDecode(sub.Keys.P256DH); string decrypted = Decryptor.Decrypt(encryptedPayload, cryptoKey, contentEncoding, encryption, userPrivateKey, userPublicKey, sub.Keys.Auth); // Make sure we've deleted any old channels now that we successfully received with this one await storage.DeleteSubscriptionsOlderThanAsync(notification.ChannelId, sub); return(decrypted); } catch { } } throw new Exception("Failed to decrypt"); }
/// <summary> /// This method hits whenever a background task execution meets the conditions /// </summary> /// <param name="args">BacklgroundActivatedArguments</param> protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) { const string PushBackgroundTaskName = "DeskhelpBackgroundNotification"; const string timerRegisterTask = "DeskHelpBackgroundDailyValidation"; const string startupTask = "DeskHelpBackgroundStartupValidation"; var deferral = args.TaskInstance.GetDeferral(); LogTelemetry("OnBackgroundActivated() triggered", SeverityLevel.Information, BuildProperties($"Background Task Name\t{args.TaskInstance.Task.Name}")); if (args.TaskInstance.Task.Name == timerRegisterTask || args.TaskInstance.Task.Name == startupTask) { var result = await validateExpirationDate(); ToastContent visual = showToast("Registration Verification", "Registration was verified succesfully.", null, false); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(visual.GetXml())); deferral.Complete(); return; } else if (args.TaskInstance.Task.Name == PushBackgroundTaskName) { try { RawNotification notification = (RawNotification)args.TaskInstance.TriggerDetails; // Decrypt the content string payload = await PushManager.GetDecryptedContentAsync(notification); //payload = payload.ToString().Replace(@"\", ""); var payloadJson = JsonObject.Parse(@payload); //dynamic json = JsonConvert.Deserialize<Dictionary<string, string>>(@payload); var applicationData2 = Windows.Storage.ApplicationData.Current; var localSettings2 = applicationData2.LocalSettings; var DeviceInfo = (string)localSettings2.Values["DeviceInfo"]; var deviceDetails = payloadJson.GetObject().GetNamedObject("deviceDetails"); var notificationID = payloadJson.GetObject().GetNamedString("notificationID"); if (deviceDetails["deviceID"].ToString().Replace("{", "").Replace("}", "").Replace("\"", "") == DeviceInfo) { bool inApp = true, inDevice = true; try { inApp = payloadJson["inApp"].ToString() == "true" ? payloadJson.GetObject().GetNamedBoolean("inApp") : false; } catch (Exception ex) { inApp = false; } try { inDevice = payloadJson["inDevice"].ToString() == "true" ? payloadJson.GetObject().GetNamedBoolean("inDevice") : false; } catch (Exception ex) { inDevice = false; } JsonArray buttons = null; try { buttons = payloadJson.GetObject().GetNamedArray("button"); } catch (Exception e) { buttons = null; } //In - Device if (inDevice && !inApp) { var title = payloadJson["title"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); var content = payloadJson["description"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); ToastContent visual = showToast(title, content, buttons, true, notificationID); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(visual.GetXml())); } else if (inApp && !inDevice) { var userID = payloadJson["userID"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); //var content = payloadJson["description"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); if (Appload == true) { await App.WebView.InvokeScriptAsync("pushNotifications", new string[] { userID }); } } else if (inApp && inDevice) { var title = payloadJson["title"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); var content = payloadJson["description"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); var userID = payloadJson["userID"].ToString().Replace("{", "").Replace("}", "").Replace("\"", ""); if (Appload == false) { ToastContent visual = showToast(title, content, buttons, true, notificationID); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(visual.GetXml())); } else { await App.WebView.InvokeScriptAsync("pushNotifications", new string[] { userID }); } } } } catch (Exception ex) { var dontWait = new MessageDialog(ex.ToString()).ShowAsync(); LogException(ex); } } deferral.Complete(); }
public async void Run(IBackgroundTaskInstance taskInstance) { _deferral = taskInstance.GetDeferral(); var client = DigitServiceBuilder.Get(); try { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; await client.LogAsync($"Received push {notification.Content}"); var opts = new DigitBLEOptions(); var content = JsonConvert.DeserializeObject <PushPayload>(notification.Content); switch (content.Action) { case PushActions.MeasureBattery: if (opts.IsConfigured) { var bleClient = new DigitBLEClient(opts); var batteryService = new BatteryService(bleClient, client); await batteryService.AddBatteryMeasurement(); } else { await client.LogAsync($"Push error: no device configured.", 3); } break; case PushActions.SendTime: if (opts.IsConfigured) { var bleClient = new DigitBLEClient(opts); try { await bleClient.SetTime(DateTime.Now); } catch (DigitBLEExpcetion e) { await client.LogAsync($"Could not send time: {e.Message}", 3); } } else { await client.LogAsync($"Push error: no device configured.", 3); } break; case PushActions.SendLocation: var locationService = new LocationService(client); await locationService.SendCurrentLocation(); break; default: break; } } catch (Exception e) { await client.LogAsync($"Unhandled background exception: {e.Message}", 3); } _deferral.Complete(); }
internal unsafe GuiNotification(RawNotification* rawNotification) : base(rawNotification) { }
public void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; NotificationTools.PushNotificationReceived(notification.Content); }
public static IAsyncOperation <string> GetDecryptedContentAsync(RawNotification notification) { return(GetDecryptedContentHelperAsync(notification).AsAsyncOperation()); }
internal unsafe SoundBankNotification(RawNotification* rawNotification) : base(rawNotification) { SoundBank = CppObject.FromPointer<SoundBank>(rawNotification->Data.SoundBank.SoundBankPointer); }
public async void Run(IBackgroundTaskInstance taskInstance) { SharedInitialization.Initialize(); InitializeUWP.Initialize(); taskInstance.Canceled += TaskInstance_Canceled; var deferral = taskInstance.GetDeferral(); try { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; long accountId = UWPPushExtension.GetAccountIdFromRawNotification(notification); if (accountId == 0) { return; } AccountDataItem account = (await AccountsManager.GetAllAccounts()).FirstOrDefault(i => i.AccountId == accountId); if (account == null) { return; } var cancellationToken = _cancellationTokenSource.Token; try { cancellationToken.ThrowIfCancellationRequested(); var result = await Sync.SyncAccountAsync(account); // If succeeded if (result != null && result.Error == null) { // Flag as updated by background task so foreground app can update data AccountDataStore.SetUpdatedByBackgroundTask(); } // Need to wait for the tile/toast tasks to finish before we release the deferral if (result != null && result.SaveChangesTask != null) { await result.SaveChangesTask.WaitForAllTasksAsync(); } } catch (OperationCanceledException) { } // Wait for the calendar integration to complete await AppointmentsExtension.Current?.GetTaskForAllCompleted(); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } finally { deferral.Complete(); } }
// New method protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) { var deferral = args.TaskInstance.GetDeferral(); try { RawNotification notification = (RawNotification)args.TaskInstance.TriggerDetails; // Decrypt the content string payload = await PushManager.GetDecryptedContentAsync(notification); // Show a notification // You'll need Microsoft.Toolkit.Uwp.Notifications NuGet package installed for this code ToastContent content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Push notification received" }, new AdaptiveText() { Text = payload } } } } }; ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); } catch (Exception ex) { ToastContent content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Failed decrypting" }, new AdaptiveText() { Text = ex.ToString() } } } } }; ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); } deferral.Complete(); }
internal unsafe CueNotification(RawNotification* rawNotification) : base(rawNotification) { CueIndex = rawNotification->Data.Cue.CueIndex; Cue = CppObject.FromPointer<Cue>(rawNotification->Data.Cue.CuePointer); SoundBank = CppObject.FromPointer<SoundBank>(rawNotification->Data.Cue.SoundBankPointer); }
public async void Run(IBackgroundTaskInstance taskInstance) { RawNotification notification = (RawNotification)taskInstance.TriggerDetails; _deferral = taskInstance.GetDeferral(); XDocument xdoc = XDocument.Parse(notification.Content); string task = xdoc.Root.Element("Task").Value; HanuDowsApplication app = HanuDowsApplication.getInstance(); var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; if (task.Equals("PerformSync")) { int count = 0; XElement xe = xdoc.Root.Element("LatestDataTimeStamp"); if (xe == null) { // Old Code --- Perform Synchronization count = await app.PerformSync(); } else { string latest_data_timestamp_string = xe.Value; DateTime latest_data_timestamp = DateTime.Parse(latest_data_timestamp_string); DateTime lastSyncTime = DateTime.Parse(localSettings.Values["LastSyncTime"].ToString()); int diff = latest_data_timestamp.CompareTo(lastSyncTime); if (diff >= 0) { // Perform Sync count = await app.PerformSync(); } } if (count > 0) { string title = "New Jokes downloaded"; string message = count + " new jokes have been downloaded."; showToastNotification(title, message); } } if (task.Equals("ShowInfoMessage")) { string mid = xdoc.Root.Element("MessageID").Value; string title = xdoc.Root.Element("Title").Value; string content = xdoc.Root.Element("Content").Value; var last_mid = localSettings.Values["ToastMessageID"]; if (last_mid != null && last_mid.Equals(mid)) { return; } localSettings.Values["ToastMessageID"] = mid; showInfoMessage(title, content); } if (task.Equals("DeletePostID")) { int id = (int)xdoc.Root.Element("PostID"); app.DeletePostFromDB(id); } if (task.Equals("SyncAllAgain")) { // Set last sync time to Hanu Epoch localSettings.Values["LastSyncTime"] = (new DateTime(2011, 11, 4)).ToString(); await app.PerformSync(); } _deferral.Complete(); }
internal unsafe WaveBankNotification(RawNotification* rawNotification) : base(rawNotification) { WaveBank = CppObject.FromPointer<WaveBank>(rawNotification->Data.WaveBank.WaveBankPointer); }