Skip to content

Latest commit

 

History

History
68 lines (56 loc) · 3.13 KB

how-do-i-ask-the-user-to-add-my-application-to-the-lock-screen.md

File metadata and controls

68 lines (56 loc) · 3.13 KB
title authors intro types categories published updated status
How do I ask the user to add my application to the lock screen?
thebeebs
For background task with timers to launch you...'
shorts
win8at8
2012/08/03 12:00:00
2012/08/03 13:00:00
archived

For background task with timers to launch you must ensure that your app is added to the lock screen. You can request to be added as a lock screen application by adding the following code to your project:

var Background = Windows.ApplicationModel.Background;

var promise = Background.BackgroundExecutionManager.requestAccessAsync().then( function(result) { switch (result) { case Background.BackgroundAccessStatus.denied: // Background activity and updates for this app are disabled by the user. break;

        case Background.BackgroundAccessStatus.allowedWithAlwaysOnRealTimeConnectivity:
            // Added to list of background apps.
            // Set up background tasks; can use the network connectivity broker.
            break;

        case Background.BackgroundAccessStatus.allowedMayUseActiveRealTimeConnectivity:
            // Added to list of background apps.
            // Set up background tasks; cannot use the network connectivity broker.
            break;

        case Background.BackgroundAccessStatus.unspecified:
            // The user didn't explicitly disable or enable access and updates. 
            break;
    }
});</pre></div>

You can also check to see if your app is a lock screen app by using the following code:

var Background = Windows.ApplicationModel.Background;

var result = Background.BackgroundApplications.getAccessStatus(); switch (result) { case Background.BackgroundAccessStatus.denied: // Disabled by the user. // Cannot display on the lock screen. break;

case Background.BackgroundAccessStatus.allowedWithAlwaysOnRealTimeConnectivity:
    // Added to list of background applications.
    // Can display on the lock screen.
    // Can set up background tasks and use the network connectivity broker.
    break;

case Background.BackgroundAccessStatus.allowedMayUseActiveRealTimeConnectivity:
    // Added to list of background applications.
    // Can display on the lock screen.
    // Can set up background tasks but cannot use the network connectivity broker.
    break;

case Background.BackgroundAccessStatus.unspecified:
    // The user didn't explicitly disable or enable.
    break;
}</pre></div>