locked
How to show toast message in javascript universal app? RRS feed

  • Question

  • I want to create universal app in visual studio 2015. How to show toast message on phone and PC? can show message if my program closed?
    Saturday, March 19, 2016 4:14 PM

Answers

  • Hi,

    These are broad questions. I would suggest taking a look at some of the documentation and examples.

    If you're interested in toast notifications then you can send them from your app in 2 primary ways;

    1. When your app code is running either foreground (running) or background (not 'running') code and it can send a toast at the current time or it can schedule them for a later time.
    2. From the Windows Notification Service (WNS) in the cloud.

    For (1) you might want to investigate how to construct and send a ToastNotification and there's a good documentation page here which shows you how to do that (in JavaScript). If you want to schedule toasts for later delivery then you'd want to also look at the AddToSchedule method and the documentation page on that here is good too.

    If you want to do this kind of work from the background then you'd need to understand background tasks and that's an area of its own but I'd recommend starting with this article and then you need to know that you can both send and schedule toasts from background tasks.

    If you want to be able to display toasts when some event happens in the 'world beyond your app' then you'd need to look at delivery from the cloud and for (2) I'd recommend this article - it looks long but it's simpler than it first seems and there are services out there (such as Azure Notification Hubs and Azure Mobile Apps) that can perform the server side of this for you to make it easier.

    I hope that helps steer you in the right direction.

    Mike

    • Proposed as answer by andrewbares7 Thursday, March 24, 2016 8:04 PM
    • Marked as answer by Xavier Xie-MSFT Thursday, March 31, 2016 10:06 AM
    Sunday, March 20, 2016 1:51 PM