Freigeben über


CONTENT MOVED: Notification Listener Documentation - Windows 10

Content moved

Please see the article on docs.microsoft.com for the latest documentation.

Comments

  • Anonymous
    June 05, 2016
    The comment has been removed
    • Anonymous
      June 05, 2016
      The comment has been removed
  • Anonymous
    June 06, 2016
    Hi Andrew,Thanks a lot for sharing this. I'm still in the process of testing feature. I noticed that "Listener_NotificationChanged" event is not triggered in the foreground. The background process seems to work fine.Also, I was wondering if the following events can be captured in this feature:- When a phone call is received. I dont think this will be placed in the notification until the call is missed. Is this correct?- Is there any events/control for the main music in the phone/PC. It would be useful to control the running music from external device like smartwatch for example.Kind RegardsEhad
    • Anonymous
      June 06, 2016
      Hey Ehad! Hmm, I'll check out the foreground event and see if it doesn't work for me either, I'm not sure if I ever tried that one out since the primary use case is background tasks (since most apps wouldn't be running while listening to notifications). But either way, if it's broken, that's a good find, so thanks!Phone calls - those actually use toast notifications, so they should theoretically appear in the listener. I haven't tested that though.Media controls - Our team doesn't own that, and I'm not sure if there's a public API available for that. Accessory apps like Microsoft Band historically used AccessoryManager, which includes access to things like notifications, and I believe media controls, but AccessoryManager is hidden behind a restricted capability and we're working on deprecating it (hence why we created Notification Listener, which is a public capability). Try posting this question on the MSDN forums.
      • Anonymous
        June 27, 2016
        Hi Andrew,I've been experimenting with this API. I found out another thing. The phone call itself is not placed in the notification while the call is in progress. It is only available in the notification once the call is missed. Is this something you can fix as part of this feature or is it the responsibility of another team?Kind RegardsEhad
        • Anonymous
          June 27, 2016
          Ah dang, that's too bad phone calls don't come through. However, with the current limited information that the Listener provides (it doesn't include any buttons from the toast), it wouldn't be very useful surfacing those phone calls anyways, since you wouldn't be able to answer/reject.There's an API for phone calls: Windows.ApplicationModel.Calls. But it doesn't look like it includes events for incoming calls.I'm not sure whether incoming calls will become their own thing, separate from notifications. There's good arguments for both options. We'll just have to see what the future brings!
          • Anonymous
            June 28, 2016
            Hi Andrew,I really hope these phone call events can be triggered. Otherwise, those notification API will be less useful for wearables.On another note, I'm not sure if you are aware of this issue. The notification event so far gives me the source and content of the notification, however, I could not find where to get the sender or the subject if it is an email. I've tested that in some apps like facebook, sms and viber. I'm not sure if this is an issue or is it something I didnt do properly!Kind RegardsEhad
        • Anonymous
          June 28, 2016
          (seems like I can't reply to your most recent comment, so replying up here)Notifications don't have any strongly typed information like email sender or email subject. Notifications are just a set of text elements. We show how to retrieve those in the "Displaying the notifications" section, basically: toastBinding.GetTextElements();
    • Anonymous
      June 07, 2016
      After testing, it looks like you're right, the foreground NotificationChanged event doesn't work! Whoops :P We're working on a fix. I'll reply to this when the fix is in Insider builds.
      • Anonymous
        June 08, 2016
        Thanks for the update ;)
        • Anonymous
          June 08, 2016
          Ok, here are another thing to test. The "toastBinding" returns null when the notification is Facebook or Email. I've tested with alarm and it works. So far I can capture the source of all notifications
          • Anonymous
            June 08, 2016
            That's another known big that we've fixed (those notifications were using the legacy ToastText02/etc toast payloads). I don't think our fix for that is in Insider builds yet. I need to update the article with a Known Preview Issues section.Either way, you should always check whether the toast binding is null for error proof code, and then skip those notifications. They'll start working soon though!
        • Anonymous
          June 15, 2016
          Hey Ehad, I have an update about the foreground event bug.The foreground event won't work for the Anniversary Update. We'll look at fixing that in the future. You'll have to use the background trigger instead. Hopefully that's fine for your app?
          • Anonymous
            June 28, 2016
            Sorry I just noticed your post. I think it's fine. I was only using it to test the notifications in the background ;)
  • Anonymous
    June 13, 2016
    Is this API available for HTML-based apps?
    • Anonymous
      June 13, 2016
      Yep! All UWP API's should work in Javascript UWP apps!
  • Anonymous
    June 27, 2016
    Hi! That is great, but. How should I deal with it if my wearable is a "write-only" device? It's just a display without any memory. I have no way to "sync". AccessoryManager API has it's own "per-app" queue for each event.Should I create some history cache in my app?
    • Anonymous
      June 27, 2016
      Hey Sergey! Yep, you should create a cache in your app. The easiest thing to do would be to use local settings, and store a list of uint in a setting entry.Using the code in the "Determining which notifications were added and removed" section, the GetNotificationsOnWearable() method would simply return the list value from your settings, and then at the end of that entire code section, you can update the list in settings by simply using a linq query to select the current notification ID's, something like: userNotifications.Select(n => n.Id).ToList();
  • Anonymous
    July 12, 2016
    The comment has been removed
    • Anonymous
      July 12, 2016
      I think there were a few bugs around the 14385 build that could be causing that. I'm not seeing any exceptions on 14387 today, I've been monitoring it today.Were you seeing this on Mobile or Desktop?
      • Anonymous
        July 12, 2016
        It was more on Mobile. Desktop was a bit more stable. On mobile, the error used to be annoying but after some time it's been working well.
    • Anonymous
      July 20, 2016
      As for the reliability and timeliness of the background task, we found an issue where it will occasionally be delayed, especially on Mobile in cases where there are battery concerns.We're looking at a fix, it'd help to know if you're planning on releasing an app using this, and therefore we know someone would benefit!
      • Anonymous
        July 20, 2016
        Hi Andrew,Thanks for the update. I've been testing this feature for about over week. It's working well so far especially after installing the latest Windows 10 builds. Do you know when we can start publishing apps with this feature? I'm not sure if everything will be ready on August, 2nd.Kind RegardsEhad
        • Anonymous
          July 21, 2016
          That's awesome to hear! Do you mind sharing what app you're creating? We'd love to know how you're using the Listener! You can find our email address in the Notifications Visualizer app (on the About page) if you don't want to share your app publically.As for releasing apps that use the Anniversary Update SDK... you have to wait till the official SDK is available, unfortunately you're not able to submit apps using the preview SDK. I don't know the timeline for when the official SDK will be released (and I probably wouldn't be able to share that information anyways).
          • Anonymous
            July 21, 2016
            Yes sure. I'll contact you soon.
  • Anonymous
    July 25, 2016
    Hi Andrew,Thanks for your great support,I've got some trouble with this, here is my questions:1- What build version of windows insider should I use? Currently I'm using insider build 14366.0, should I Change it?2- What changes/upgrades should I do in Visual studio? Currently I'm using visual studio v3.3- Is there any sample that I can use? any thing I can learn from? I just find a documentation of it but it is not completely practical?Thanks.
    • Anonymous
      July 27, 2016
      Hey Reza!1. If you're talking about the OS that you're using on your computer/phone, I would definitely recommend upgrading to build 14393 (the latest Insider build), there were a number of Listener bug fixes that probably weren't available in your current build.If you're talking about which SDK to use, I believe the 14366 SDK is the latest one available? The SDK won't change anything - our bug fixes all occurred in the OS itself.2. Doesn't matter which version of Visual Studio you use - Update 3 is the latest, that'll be fine.3. We have a sample app that replicates Action Center, you can check it out here: https://github.com/WindowsNotifications/NotificationListenerActionCenterAppWe don't have any other samples. What type of sample would you find most useful? I'd love to know, so that we know what we should focus on!Thanks!Andrew
      • Anonymous
        August 06, 2016
        Thanks alot
      • Anonymous
        November 15, 2016
        Hi Andrew,Does this sample have a C++ version?
        • Anonymous
          November 15, 2016
          Hey Serna! No, we don't have a C++ sample of this, hopefully it's not too difficult to translate to C++.If we get more requests for C++ samples, we'll consider including C++ for this and future documentation/samples.
          • Anonymous
            November 17, 2016
            Hi Andrew, Thanks for the reply.For our case, we just want to get notified if any new toast notification comes in, and we doesn't care about its content or any dismissed notification. Is there any simpler interface to do this? or, I still have to compare the delta? Thanks
  • Anonymous
    August 16, 2016
    Hey there!  string titleText = textElements.FirstOrDefault()?.Text;and  string bodyText = string.Join("\n", textElements.Skip(1).Select(t => t.Text));are returning non-alphabetical characters (low-values mixed with letters).Kind RegardsLuis Silva
    • Anonymous
      August 17, 2016
      Hmm interesting, do you have a specific repro of that issue? Is it happening for every single notification? Or just a specific app?Mobile or Desktop? What build are you running? What language/culture is your machine?
  • Anonymous
    August 30, 2016
    Hi Andrew,I noticed a similar thing with the new update (version 14905). Apps like timer and some games have the first value (usually the name of the app) is returned as the path (@C:/.....). Kind RegardsEhad
    • Anonymous
      August 31, 2016
      Hmm interesting, are these all third party apps/games? Can you give me specific names of the apps? I'm not seeing any "C:" paths from my phone, but I likely don't have those same apps installed. Thanks!
      • Anonymous
        September 20, 2016
        Hi Andrew,Sorry for the late reply. I just saw your comment. I happened on some games that send notifications. I'll try to capture that when it happens again.Kind RegardsEhad
      • Anonymous
        September 21, 2016
        The comment has been removed
  • Anonymous
    December 02, 2016
    I am working with notifications listener currently and I found few things that I need to ask you, it would be great if you clear me these things.1. await Launcher.LaunchUriAsync(new Uri("ms-settings:privacy-notifications")); should launch the notification section in privacy settings but it doesn't. is it a problem or I am getting this wrong ?.2. if change access in settings > privacy > notifications it closes the foreground app , is there any way to fix it?
    • Anonymous
      December 06, 2016
      Hey Shibly, I think we talked on FB, but I'm going to post a comment here for the benefit of everyone else too!1) We're looking into why the URL scheme for settings doesn't work. Thank you for reporting that!2) For when the user revokes access from the settings, we purposefully close apps using the API to respect the user's decision to revoke access (otherwise it might feel like the app still has access since the app could have cached some notifications in memory).However, when the user grants access, you might be right that it'd be a better experience to not close the app. One of the reasons to close the app, however, is because some apps might only do their registration code on first launch, rather than on resume, so if the user returns to the app after granting access, the app still won't be behaving correctly. But we're re-evaluating this decision thanks to your feedback!
  • Anonymous
    December 05, 2016
    i am getting error in app.xaml.cs in onBackgroundActivated function at " await MyWearableHelpers.SyncNotifications();" system shows "task doesn't contains definition for 'syncNotifications' and no extension method is accepting first argument of type 'Task'"
    • Anonymous
      December 06, 2016
      Hey Asad! The "MyWearableHelpers.SyncNotifications()" function is a function that you would have to create yourself. I'll add a comment in the code snippet to make that clear.That function should do something similar to the code provided in the "Determining which notifications were added and removed" section. We also have a sample app on GitHub that replicates Action Center which you could try out if you need some more help with the API's: https://github.com/WindowsNotifications/NotificationListenerActionCenterAppLet me know if you have any further questions!!