WIN8 Push Notification Small note

Source: Internet
Author: User

http://blog.csdn.net/nacl025/article/details/8998552

http://blog.csdn.net/nacl025/article/details/9037247

Open a push channel (if it does not already exist), or connect to an existing push channel. If your app created a push channel in a previous app instance, there might be a push channel. If the push channel is bound to a tile or Toast notification, the push channel still exists after the app exits, so that you can still receive these notifications even if the app is not running.

Apps that use raw notifications must implement the Httpnotificationreceived event to receive raw data in the notification. (Raw notifications cannot be received if the app is in a non-running state)

If your app is already running, the TOAST notification is ignored unless you register for the shelltoastnotificationreceived event. Your app can then determine how it wants to respond to Toast notifications.

Original notification

1. The original notification is the only notification type that can trigger a background task. Although toast, tile, and badge push notifications do not trigger background tasks, background tasks triggered by the original notification can update the tile and invoke Toast notifications through local API calls.

2. For each application, only one background task can be run at a time. If you trigger a background task for an app that is already running a background task, you must complete the first background task before you can run the new background task.

3. If the app is running, the notification delivery event takes precedence over the background task, and the app will have the first opportunity to process the notification. The notification delivery event handler can be set to true by setting the Pushnotificationreceivedeventargs.cancel property of the event To specify that the handler should not pass the original notification to its background task after exiting. If the Cancel property is set to false or not set (the default value is false), the original notification triggers the background task after the notification delivery event handler finishes its work.

Consider using a different communication method before selecting the background task that was triggered by the original notification. Most apps should not need to implement background tasks. To make your app use background tasks, the app must be one of the few apps that allows pinning to the lock screen. Your app will contend with these slots, and the user has ultimate control over the apps that occupy the slots. There is no guarantee that your application is one of them. By using other mechanisms that implement communication in your app, such as standard push notifications or Toast updates, you can prevent users from having to choose between your app and other apps they care about.

Some workarounds for background tasks: (Note that toast\title notifications can be run in the background, but cannot touch the background task)

    • To attract users ' attention, send a Toast push notification.
    • To update your tile, use a tile push notification.

4. Background task triggered by the original notification: the user must explicitly give the app permission to run background tasks, which is granted when the user adds the app to its lock screen. Only seven apps can have this right at a time. 5. When your app's cloud service sends notifications to Windows, your app has the opportunity to intercept and process the notification before displaying a Toast, updating a tile or badge, or sending the original notification to a background task. It can also block the display or update of these elements. Implementing a notification Send event handler is optional. When the app wants to process and block incoming (E. Cancel = True, the option is most useful when the Toast is not displayed to the user. [CSharp]View Plaincopy
  1. Pushnotificationchannel channel = null;
  2. Channel. Pushnotificationreceived + = onpushnotification;
  3. Try
  4. {
  5. Channel = await pushnotificationchannelmanager.createpushnotificationchannelforapplicationasync ();
  6. }
  7. catch (Exception ex)
  8. {
  9. // ...   
  10. }
  11. string content = null;
  12. Private async void Onpushnotification (pushnotificationchannel sender, Pushnotificationreceivedeventargs e)
  13. {
  14. String notificationcontent = String.Empty;
  15. switch (e.notificationtype)
  16. {
  17. Case Pushnotificationtype.badge:
  18. Notificationcontent = E.badgenotification.content.getxml ();
  19. Break ;
  20. Case Pushnotificationtype.tile:
  21. Notificationcontent = E.tilenotification.content.getxml ();
  22. Break ;
  23. Case Pushnotificationtype.toast:
  24. Notificationcontent = E.toastnotification.content.getxml ();
  25. Break ;
  26. Case Pushnotificationtype.raw:
  27. Notificationcontent = e.rawnotification.content;
  28. Break ;
  29. }
  30. E.cancel = true;
  31. }

WIN8 Push Notification Small note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.