Tuesday 2 August 2016

Action Center in Universal Windows Apps

  
Action Center is a system area, where user can have setting panel(composite of several system settings) and notifications list grouped by App ordered chronologically inside action center. These are the notification which user has missed to attempt when it received or user has ignored it after swiping left to right on it.  User can access action center : Mobile : Swiping down from top edge of the screen Desktop : Swiping left from right edge of the screen.  App can have maximum 20 notification into their group.It follows the Queue format, last element is flushed out once a new notification is pushed into the group. Ideally expiration date for an notification in action center is 7 days unless an earlier expiration time is specified during the creation of the toast.  

Desktop :  
 Inserting image... 

 Mobile :   
Inserting image...   

There are various Action Center Management APIs are available 
We can do: 
Remove one or many notifications. 
Tag and group notifications. 
Replace a notification with a new one. 
Set an expiration on notifications. 
Send "Ghost Toast" notifications(only show up in notification center)   

void RemoveNotificationHistory() 
{ 
    ToastNotificationHistory tH = ToastNotificationManager.History; 
    tH.Remove("My App toast 1"); 
    tH.RemoveGroup("Whatsapp"); 
} 

  App responsibilities on notification: 
Apps can inform user of 'unread' items in ways(Count on tile,listed in action center). 
App+Action center+Tile(s) must tell a consistent story for good experience. 
-User taps on toast popup or in Action center>App opens at corresponding item? 
-User opens app and reads unread items>Notification in action center removed? 
User dismisses Action Center Notification>Tile badge count changes?    

ToastNotificationHistoryChangesTrigger-
Fires whenever a user dismisses a notification from action center or when an app adds or removes or replace a notification.   Use to trigger a Background task in which you can maintain consistency of un actioned item counts in app state and on tiles. 
  
public sealed class ActionCenterChangedTask : IBackgroundTask 
   { 
       public void Run(IBackgroundTaskInstance taskInstance) 
       { 
         var toastNotifications = ToastNotificationManager.History.GetHistory(); 
           if(toastNotifications!=null) 
           { 
               var toastCount = toastNotifications.Count; 
               if(toastCount == 0) 
               { 
                   BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); 
               } 
               else 
               { 
                   XmlDocument xmlBadge = 
                   BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); 
                   XmlElement badgeElement = (XmlElement)xmlBadge.SelectSingleNode("/badge"); 
                   badgeElement.SetAttribute("value", toastCount.ToString()); 
                   BadgeNotification badgeNotification = newBadgeNotification(xmlBadge); 
                   BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification); 
               } 
           } 
       } 
   } 
  

No comments:

Post a Comment