Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Can't add nfc plugin as shown in readme #1131

Open
gato25 opened this issue Mar 30, 2024 · 1 comment
Open

[docs] Can't add nfc plugin as shown in readme #1131

gato25 opened this issue Mar 30, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation plugin: nfc

Comments

@gato25
Copy link

gato25 commented Mar 30, 2024

Describe the bug

Tried to follow https://docs.rs/crate/tauri-plugin-nfc/latest

My lib.rs

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_nfc::init())
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

But this gives an error

.plugin(tauri_plugin_nfc::init())
| ^^^^ not found in `tauri_plugin_nfc

How do i solve this ?

I tried to import use tauri_plugin_nfc::init; but still same issue.

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 123.0.2420.65
    ✔ MSVC: Visual Studio Build Tools 2022
    ✔ rustc: 1.77.0 (aedd173a2 2024-03-17)
    ✔ cargo: 1.77.0 (3fe68eabf 2024-02-29)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.16.1
    - pnpm: 8.15.4
    - npm: 9.5.1

[-] Packages
    - tauri [RUST]: 2.0.0-beta.13
    - tauri-build [RUST]: 2.0.0-beta.10
    - wry [RUST]: 0.37.0
    - tao [RUST]: 0.26.1
    - @tauri-apps/api [NPM]: 2.0.0-beta.5
    - @tauri-apps/cli [NPM]: 2.0.0-beta.9

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

Stack trace

No response

Additional context

No response

@FabianLars
Copy link
Member

Thanks, we will update the readme.

Because the plugin is mobile-only you have to register it like so:

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
  tauri::Builder::default()
    .setup(|app| {
        #[cfg(mobile)]
        {
            app.handle().plugin(tauri_plugin_nfc::init())?;
        }
    })
    .invoke_handler(tauri::generate_handler![greet])
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Mar 30, 2024
@FabianLars FabianLars added the documentation Improvements or additions to documentation label Mar 30, 2024
@FabianLars FabianLars changed the title [bug] Can't add nfc plugin [docs] Can't add nfc plugin as shown in readme Mar 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation plugin: nfc
Projects
None yet
Development

No branches or pull requests

2 participants