#plugin #mobile-onbackpressed-listener

sys tauri-plugin-mobile-onbackpressed-listener

This plugin mainly provides event listener for controlling the onBackpressed action on mobile devices

2 stable releases

new 2.0.1 Mar 29, 2025

#416 in GUI

MIT license

78KB
364 lines

Contains (JAR file, 44KB) gradle-wrapper.jar

Tauri Plugin mobile-onbackpressed-listener

Platform Supported
Linux x
Windows x
macOS x
Android
iOS

Install

This plugin requires a Rust version of at least 1.77.2

There are three general methods of installation that we can recommend.

  1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
  2. Pull sources directly from Github using git tags / revision hashes (most secure)
  3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)

Install the Core plugin by adding the following to your Cargo.toml file:

src-tauri/Cargo.toml

Manually

[target.'cfg(any(target_os = "ios", target_os = "android"))'.dependencies]
tauri-plugin-mobile-onbackpressed-listener = "2.0.0"

Automatically

use the cargo add command to install it automatically (mobile targets only):

cargo add tauri-plugin-mobile-onbackpressed-listener --target 'cfg(any(target_os = "ios", target_os = "android"))'

Usage

First you need to register the core plugin with Tauri: src-tauri/src/lib.rs

pub fn run() {
  tauri::Builder::default()
    .setup(|app| {
      #[cfg(any(target_os = "ios", target_os = "android"))]
      app.handle().plugin(tauri_plugin_mobile_onbackpressed_listener::init())?;

      Ok(())
    })
    .invoke_handler(tauri::generate_handler![greet])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}
import { registerBackEvent } from "jsr:@kingsword/tauri-plugin-mobile-onbackpressed-listener"

Dependencies

~18–53MB
~853K SLoC