new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Tauri · Plugins and security · all subjects

permissions & scopes

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

iOS plugin permission handling

For iOS plugins that require permissions, override the `checkPermissions` and `requestPermissions` functions. The `checkPermissions` function should resolve with a dictionary mapping permission names to their current state. The `requestPermissions` function should request permissions and then resolve with a dictionary mapping permission names to their granted state.

Check and request permissions from Rust

In Rust, use `self.0.run_mobile_plugin::<PermissionResponse>("checkPermissions", ())` to check permissions and `self.0.run_mobile_plugin::<PermissionResponse>("requestPermissions", requestPayload)` to request permissions. Define response structs implementing Deserialize with fields for each permission.

Plugin event listening requires capability permission

Listening to plugin events from JavaScript is gated by the same capability and permission system that gates plugin commands. Add the plugin's permission (commonly `<plugin-name>:default`, or a specific `allow-listen-*` permission if the plugin defines one) to the `permissions` array of a capability under `src-tauri/capabilities/`.

Android permission definition in TauriPlugin annotation

Define required permissions in the @TauriPlugin annotation using a permissions array. Each permission includes an Android Manifest permission string and an alias for identification in code. Example: @TauriPlugin(permissions = [Permission(strings = [Manifest.permission.POST_NOTIFICATIONS], alias = "postNotification")])

iOS permission handling methods

In iOS, override checkPermissions and requestPermissions functions to handle permissions. checkPermissions should return the current permission states as a dictionary. requestPermissions should request the permissions and then resolve with the granted states.

Tauri automatic permission commands

Tauri automatically implements two commands for plugins: checkPermissions and requestPermissions. These can be called directly from JavaScript or Rust.

JavaScript checkPermissions invocation

In JavaScript, call 'plugin:<plugin-name>|checkPermissions' using invoke() to check permission status. Returns an object with permission states. If state is 'prompt-with-rationale', show users information about why permissions are needed. If state starts with 'prompt', request permissions using 'plugin:<plugin-name>|requestPermissions' with a permissions array.

Rust permission handling pattern

In Rust, create deserializable structs for permission responses and serializable structs for permission requests. Use run_mobile_plugin with the response struct type to call requestPermissions and checkPermissions. Use tauri::plugin::PermissionState enum for permission state values.

Give your agent this brain