| 1 | // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command |
| 2 | #[tauri::command] |
| 3 | fn greet(name: &str) -> String { |
| 4 | format!("Hello, {}! You've been greeted from Rust!", name) |
| 5 | } |
| 6 | |
| 7 | #[cfg_attr(mobile, tauri::mobile_entry_point)] |
| 8 | pub fn run() { |
| 9 | #[cfg(debug_assertions)] |
| 10 | let builder = tauri::Builder::default().plugin(tauri_plugin_devtools::init()); |
| 11 | #[cfg(not(debug_assertions))] |
| 12 | let builder = tauri::Builder::default(); |
| 13 | |
| 14 | builder |
| 15 | .invoke_handler(tauri::generate_handler![greet]) |
| 16 | .setup(|#[allow(unused)] app| { |
| 17 | // Android-only plugin. |
| 18 | #[cfg(target_os = "android")] |
| 19 | { |
| 20 | app.handle().plugin(tauri_plugin_admob::init())?; |
| 21 | } |
| 22 | Ok(()) |
| 23 | }) |
| 24 | .run(tauri::generate_context!()) |
| 25 | .expect("error while running tauri application"); |
| 26 | } |