Search code examples
c#windows-runtimewindows-store-apps

Access App capabilities programmatically


I am using microphone, location, internet capabilities in Windows 8.1 Store application. How can I programmatically access the capabilities to which user agrees to go on.


Solution

  • For Internet, the user does not control this capability unless they disable networking system wide. This is similarly true for access to the media libraries, which is always allowed if you declare the capability.

    For microphone and location, as well as webcam, the user will be prompted for consent the first time you attempt to use an applicable API. If they consent, the API will succeed. If not, the API will fail with Access Denied. The user can then go to the Settings charm for the app, tap Permissions, and change that consent at any later time.

    The upshot of this is that you determine whether a capability is turned on or off is by attempting to call an API that uses it and then catch the Access Denied exceptions. You can then notify the user that they must turn permissions back on if they want to use that feature.