private static ReceivedNotification WSAReceivedNotificationToReceivedNotification(WSA.ReceivedNotification it) { return(new UTNotifications.ReceivedNotification(it.Title, it.Text, it.Id, it.UserData, it.NotificationProfile, it.BadgeNumber)); }
public static void HandleReceivedNotifications(string appArguments, out IList <ReceivedNotification> allReceivedNotifications, out ReceivedNotification clickedNotification) { allReceivedNotifications = null; clickedNotification = null; if (ApplicationData.Current == null) { return; } var settings = ApplicationData.Current.LocalSettings; if (settings == null || settings.Values == null || settings.Values.Count == 0) { return; } clickedNotification = GetClickedNotification(appArguments, settings); long currentTime = GetCurrentUnixTimeSeconds(); if (HandleNotifications() && NotificationsEnabled()) { string[] keys = new string[settings.Values.Count]; settings.Values.Keys.CopyTo(keys, 0); foreach (var it in keys) { if (it.StartsWith(STORE_KEY_PREFIX)) { try { ApplicationDataCompositeValue registeredNotification = (ApplicationDataCompositeValue)settings.Values[it]; if (registeredNotification == null) { continue; } long lastTriggerInSeconds = (long)registeredNotification["lastTriggerInSeconds"]; long lastTimeHandled = (long)registeredNotification["lastTimeHandled"]; int intervalSeconds = (int)registeredNotification["intervalSeconds"]; bool handle; if (intervalSeconds > 0) { //Repeated handle = (currentTime - lastTimeHandled > intervalSeconds); } else { //One shot handle = (currentTime > lastTriggerInSeconds && lastTimeHandled != (long)(-1)); } if (handle) { if (allReceivedNotifications == null) { allReceivedNotifications = new List <ReceivedNotification>(); } allReceivedNotifications.Add(ReadReceivedNotification(registeredNotification)); if (intervalSeconds > 0) { //Repeated long newLastTimeHandled = (lastTriggerInSeconds - currentTime) % intervalSeconds; if (newLastTimeHandled > 0) { newLastTimeHandled -= intervalSeconds; } newLastTimeHandled += currentTime; registeredNotification["lastTimeHandled"] = newLastTimeHandled; settings.Values[it] = registeredNotification; } else { //One shot registeredNotification["lastTimeHandled"] = (long)(-1); } settings.Values[it] = registeredNotification; } } catch { continue; } } } } }
public static void HandleReceivedNotifications(string appArguments, out IList <ReceivedNotification> allReceivedNotifications, out ReceivedNotification clickedNotification) { throw new NotImplementedException(); }