geode.utils.permission reads and requests operating system permissions. This matters on mobile.
On Windows and macOS, accepted permissions return granted. Use the Permission table for the values.
A bad permission value raises a Lua error.
| Name | Value |
|---|---|
ReadAllFiles |
3 |
RecordAudio |
4 |
geode.utils.permission.getPermissionStatus(permission: number) -> booleanReturns whether the permission is granted.
geode.utils.permission.requestPermission(permission: number, callback: (granted: boolean) -> ()) -> ()Asks the system for the permission. The callback runs later on the main thread with the result. See Getting started for the shared runtime threading rule.
geode.utils.permission.Permission -> { ReadAllFiles: number, RecordAudio: number }A table of the permission values.
local perm = geode.utils.permission
if not perm.getPermissionStatus(perm.Permission.RecordAudio) then
perm.requestPermission(perm.Permission.RecordAudio, function(granted)
print("granted:", granted)
end)
endsrc/bindings/geode/GeodeSmallBindings.cpp