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

mobile plugins

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

Native mobile functionality for Tauri plugins

A Tauri plugin can now access iOS via Swift and Android APIs via Kotlin or Java code, simplifying usage of platform interfaces such as camera or geolocation. To bootstrap the iOS and Android projects on an existing plugin, run `tauri plugin ios add` and `tauri plugin android add`. New plugins automatically include all the configuration needed to write native mobile code.

Android plugin implementation example

Example Android plugin in Kotlin that takes a string value and resolves an object: ```kotlin package com.plugin.example import android.app.Activity import app.tauri.annotation.Command import app.tauri.annotation.TauriPlugin import app.tauri.plugin.JSObject import app.tauri.plugin.Plugin import app.tauri.plugin.Invoke @TauriPlugin class ExamplePlugin(private val activity: Activity): Plugin(activity) { @Command fun ping(invoke: Invoke) { val value = invoke.getString("value") ?: "" val ret = JSObject() ret.put("value", value) invoke.resolve(ret) } } ```

iOS plugin implementation example

Example iOS plugin in Swift that takes a string value and resolves an object: ```swift import UIKit import WebKit import Tauri class ExamplePlugin: Plugin { @objc public func ping(_ invoke: Invoke) throws { let value = invoke.getString("value") invoke.resolve(["value": value as Any]) } } @_cdecl("init_plugin_example") func initPlugin(name: SRString, webview: WKWebView?) { Tauri.registerPlugin(webview: webview, name: name.toString(), plugin: ExamplePlugin()) } ```

Plugin initialization code for cross-platform plugin

Rust code to initialize a plugin with iOS and Android support: ```rust use tauri::{ plugin::{Builder, TauriPlugin}, Manager, Runtime, }; #[cfg(target_os = "ios")] tauri::ios_plugin_binding!(init_plugin_example); pub fn init<R: Runtime>() -> TauriPlugin<R> { Builder::new("example") .setup(|app, api| { #[cfg(target_os = "android")] api.register_android_plugin("com.plugin.example", "ExamplePlugin")?; #[cfg(target_os = "ios")] api.register_ios_plugin(init_plugin_example)?; Ok(()) }) .build() } ```

Recreate mobile projects for 2.0.0-alpha.4

When updating to 2.0.0-alpha.4, recreate the mobile projects with: ```shell rm -r src-tauri/gen tauri android init tauri ios init ```

Mobile native APIs in Tauri v2

Tauri v2 comes with built-in support for mobile native APIs including notifications, dialogs, NFC, barcode reading, biometric authentication, clipboard, and deep link. More APIs will be added after the stable release.

Tauri v2 introduces mobile support

Tauri v2 adds support for both Android and iOS, allowing developers to bring existing desktop implementations and seamlessly port them to mobile with access to native APIs.

Tauri 2.0 mobile plugins contributed by CrabNebula

CrabNebula contributed multiple mobile plugins to the official Tauri plugin repository: NFC, Barcode Scanner, Biometric, Haptics, and Geolocation. These plugins are available for production use on Android and iOS.

Tauri 2.0 mobile plugin system with native languages

Tauri 2.0 supports writing native code in Swift on iOS and Kotlin on Android and directly exposing functions to the Tauri frontend. On Android, this is done using Annotations (@Command). On iOS, this is done by implementing a Subclass (YourPluginClass: Plugin). Alternatively, Swift or Kotlin code can be invoked from a Rust based Tauri command.

Tauri 2.0 mobile platform support

Tauri 2.0 extends single UI code base support from desktop operating systems to iOS and Android. Native development is done using operating system native languages (Swift and Kotlin) to build an interface for the Rust code and to allow developers to write part of their functionality in these languages. Development is supported with an emulator or a real device with tooling to make the process as seamless as possible.

Not all official plugins support mobile in Tauri 2.0

On mobile not all of the official plugins are supported. Some are by design not a good fit for mobile and some are just not implemented to support mobile yet.

Give your agent this brain