Elevate in your app
Last updated
Last updated
You might have interacted with one already: ArcOS has a Secure Context, basically a glorified confirmation dialog that asks the user if they want to continue with any given operation. You can compare this to a sudo
prompt in macOS or Linux, or the User Account Control dialog on Windows.
There are two ways to elevate: either you call UserDaemon.manuallyElevate
(manual elevation), or you call AppProcess.elevate
(predefined elevation). Here's both methods expained in detail:
To manually elevate, call the UserDaemon.manuallyElevate
method in your process class. Do it like this:
Here I'm asking the user permission to delete the Minesweeper application, with a medium severity and an image URL I loaded using . The asynchronous function returns a boolean that returns true
if the user permitted the elevation request.
A predefined elevation is saved in the elevations
property of your app's process. For example, if you have an elevation that needs to be presented a bunch of times, you can save it in this property and elevate using an ID later. Here's how:
And then anywhere else in your app process:
You should elevate only when you're about to perform big operations that the user might regret. Basically, if you're about to delete an app, change a security setting, kill a process, you're expected to elevate. You don't have to elevate for deleting a note from a ToDo list, just use the MessageBox
function for that.