次の方法で共有


Managing toast notifications in action center (Windows Phone Store apps)

Action center, introduced in Windows Phone 8.1, enables users to quickly access certain system settings of their choice, as well as their toast notifications. You access action center by a downward swipe from the top of the phone's screen, and you can customize it via the phone's Settings app.

For more info about toast notifications in general, see the Toast notification overview.

Overview of action center

By default, when you send a toast notification, a pop-up UI element at the top of the phone's screen displays the contents of the notification to the user. The user can make one of three responses to a toast:

  • Tap the toast. This takes the user to your app, where you can show further info relevant to the notification.
  • Explicitly dismiss the toast.
  • Ignore the toast. The toast disappears automatically after a few seconds.

In the last two cases, action center gives the user a place to see and possibly act on those missed or dismissed toasts. It can also include toasts sent directly to action center and never shown in a pop-up UI.

To reduce the number of toasts the user sees from your app, you can use the SuppressPopup property, available for both the ToastNotification and ScheduledToastNotification classes. When you set this property to true, the toast is sent directly to action center and is not displayed in pop-up UI.

A single app can show a maximum of 20 toast notifications in action center. Tapping a notification launches the app, typically to a view associated with the notification's contents, and removes the notification from action center. Each app has its own action center queue, which is managed by the system on a first in, first out (FIFO) basis. If more notifications are received than the queue can hold, the system displays a More Notifications message to inform the user that they have missed more notifications from this app than are shown. Tapping on that message simply launches your app.

Grouping and tagging toast notifications

A toast notification can be labeled with a tag, assigned to a group, or both. Tags and groups are used to replace or remove notifications from action center. Tag and group strings are applied via the Tag and Group properties of the ScheduledToastNotification and ToastNotification classes. There is no specific format to tag or group strings—use whatever you like as appropriate to your app.

Tags do not need to be unique, which means you can have any of these situations:

  • A single notification with a particular tag, either in a group or ungrouped
  • Multiple notifications in the same group with the same tag
  • Multiple notifications with the same tag but in different groups

The ToastNotificationHistory class gives you three ways (with overloads) to remove toast notifications from action center:

  • Clear: Clears all notifications.
  • Remove: Enables these scenarios:
    • Remove all notifications with a specific tag and no group affiliation
    • Remove all notifications with both a specific tag and a specific group
    • Remove all notifications for a specified app with a specific tag and no group affiliation
    • Remove all notifications for a specified app, with both a specific tag and a specific group
  • RemoveGroup: Enables these scenarios:
    • Remove all notifications with a specific group label
    • Remove all notifications for a specified app, with a specific group label

To learn more about how your app can manage its toast notifications in action center, see Quickstart: Managing toast notifications in action center.

The action center and Windows Push Notification Services (WNS)

You can also interact with action center when you send your toast push notifications from your app server via Windows Push Notification Services (WNS). New push notification service request and response headers have been added to WNS to support action center scenarios:

  • The X-WNS-Tag and X-WNS-Group headers provide the Tag and Group properties discussed previously.
  • The X-WNS-SuppressPopup header causes the toast to be delivered directly to action center without raising the pop-up UI on the user's phone.
  • The X-WNS-TTL header specifies the maximum time the toast will be visible in action center before it expires and is removed. The default value is 7 days.
  • The X-WNS-Match header, used in an HTTP DELETE request, instructs action center to remove a specific toast or group of toasts.

WNS and offline scenarios

For many reasons (for example, low signal strength or airplane mode), a device can be in a disconnected state, unable to access a network, and therefore unable to receive push notifications. When a target device is in a disconnected state, WNS caches an app's notifications in a queue, for delivery when the device reconnects. However, the queue size is limited and notifications are cached on a FIFO basis, which can cause older notifications to be dropped.

When the device returns to a connected state, the cached toasts are delivered to the device along with an indicator of whether any toasts were dropped. The following table summarizes what is sent to the device when it reconnects.

WNS queue state when the device is reconnected What is delivered to the device
WNS has one new notification. No notifications were dropped while the device was in a disconnected state.

The cached notification is sent to action center.

If the X-WNS-SuppressPopup header was not set on the toast, a pop-up UI is also displayed on the device.

WNS has multiple new notifications. No notifications were dropped while the device was in a disconnected state.

All cached notifications are sent to action center.

The device shows a single summary toast for the app, to inform the user that new notifications have arrived.

WNS has multiple notifications. One or more notifications was dropped while the device was in a disconnected state.

All cached notifications are sent to action center.

"More Notifications" is displayed in action center.

The device shows a single summary toast for the app, to inform the user that new notifications have arrived.

 

Tip  When a device reconnects to the network, a maximum of one toast is shown to the user in order to avoid a sudden flood of notifications. In the case of a single notification, tapping the toast launches the app in a context related to the toast content. In the case of a summary toast, the app launches normally.

 

Quickstart: Managing toast notifications in action center

Action Center Quickstart Sample

Push notification service request and response headers