locked
How can I get windows setting notification value? RRS feed

  • Question

  • Hi,

    I'd like to get user's notification(alarm) setting of windows in my app (developing by c#)

    How can I do that?

    I want to show an alert like "You turned off notification on windows settings so you can't look any toast." when open my app if user sets my app's notification setting is off.

    Any idea for this?



    Tuesday, October 13, 2015 2:36 PM

All replies

  • Hi GHLab,

    You can use ToastNotifier.Setting property to check the notification setting of your app in "Settings". This property returns a NotificationSetting enumeration. It returns Enabled if the toast can be shown; otherwise, one or more reasons that the toast will be blocked. Following is a simple sample

    //DisabledForApplication indicates user has disabled notifications for this app.
    if (ToastNotificationManager.CreateToastNotifier().Setting == NotificationSetting.DisabledForApplication)
    {
        var messageDialog = new Windows.UI.Popups.MessageDialog("You turned off notification on windows settings so you can't look any toast.");
        await messageDialog.ShowAsync();
    }
    

    Note that When toast notifications have been disabled at more than one level, this property value reflects the setting with the largest scope. Precedence is as follows, from largest scope to smallest:

    1.DisabledByManifest
    2.DisabledByGroupPolicy
    3.DisabledForUser
    4.DisabledForApplication

    If toast notifications have been disabled both by the user and by group policy, this property returns DisabledByGroupPolicy. So just use DisabledForApplication may be not enough. You'd better use these enumeration members according to your scenario.

    Hope this helps.

    Regards,

    Jay

    Wednesday, October 14, 2015 9:00 AM