public /*async*/ void EnableForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } enabled = true; }
public void DisableForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } enabled = false; }
public void DisableForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } enabled = false; //notificationListener.NotificationChanged -= NotificationListener_NotificationChanged; }
public /*async*/ void NotifyImmediatelyForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } var service = base.ParentService as AlertNotificationService; var value = new byte[] { (byte)AlertCategoryId.SimpleAlert, Convert.ToByte(service.UnreadCount) }; Value = GattConvert.ToIBuffer(value); base.NotifyValue(); }
public /*async*/ void EnableForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } //if (notificationListener.GetAccessStatus() != UserNotificationListenerAccessStatus.Allowed) //{ // await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( // CoreDispatcherPriority.Normal, // async () => // { // var status = await notificationListener.RequestAccessAsync(); // }); //} //notificationListener.NotificationChanged += NotificationListener_NotificationChanged; enabled = true; }
//private async void NotificationListener_NotificationChanged(UserNotificationListener sender, UserNotificationChangedEventArgs args) //{ // var notifications = await notificationListener.GetNotificationsAsync(NotificationKinds.Toast); // var writer = new DataWriter(); // writer.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8; // writer.WriteByte((byte)AlertCategoryId.SimpleAlert); // writer.WriteByte(Convert.ToByte(notifications.Count)); // if (notifications.Count > 0) // { // writer.WriteString(notifications.Last().Id.ToString()); // } // else // { // writer.WriteString(""); // } // Value = writer.DetachBuffer(); // NotifyValue(); //} public async void NotifyImmediatelyForCategory(AlertCategoryId categoryId) { if ((categoryId != AlertCategoryId.SimpleAlert) && (categoryId != AlertCategoryId.All)) { return; } //if (notificationListener.GetAccessStatus() != UserNotificationListenerAccessStatus.Allowed) //{ // await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( // CoreDispatcherPriority.Normal, // async () => // { // var status = await notificationListener.RequestAccessAsync(); // }); //} //var notifications = await notificationListener.GetNotificationsAsync(NotificationKinds.Toast); var service = base.ParentService as AlertNotificationService; var writer = new DataWriter(); writer.UnicodeEncoding = Windows.Storage.Streams.UnicodeEncoding.Utf8; writer.WriteByte((byte)AlertCategoryId.SimpleAlert); writer.WriteByte(Convert.ToByte(service.UnreadCount)); if (service.UnreadCount > 0) { writer.WriteString(service.LastNotification.Name.ToString()); } else { writer.WriteString(""); } Value = writer.DetachBuffer(); base.NotifyValue(); }