Haptics(ハプティクス/触覚)
Plugin 説明内容の英語表記部分について Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
Android と iOS での触覚フィードバックと振動
Android には振動サポートの標準/必須要件がないため、最近リリースされた機種も含めて、より手頃な価格帯の携帯電話ではフィードバック API が正しく動作しない可能性があります。
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | | |
| linux | | |
| macos | | |
| android | ||
| ios |
はじめに、「haptics」プラグインをインストールしてください。
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
npm run tauri add hapticsyarn run tauri add hapticspnpm tauri add hapticsdeno task tauri add hapticsbun tauri add hapticscargo tauri add haptics-
src-tauriフォルダで次のコマンドを実行して、このプラグインをCargo.toml内のプロジェクトの依存関係に追加します:cargo add tauri-plugin-haptics --target 'cfg(any(target_os = "android", target_os = "ios"))'` -
追加したプラグインを初期化するために
lib.rsを修正します:src-tauri/src/lib.rs #[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() {tauri::Builder::default().setup(|app| {#[cfg(mobile)]app.handle().plugin(tauri_plugin_haptics::init());Ok(())}).run(tauri::generate_context!()).expect("error while running tauri application");} -
お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
npm install @tauri-apps/plugin-hapticsyarn add @tauri-apps/plugin-hapticspnpm add @tauri-apps/plugin-hapticsdeno add npm:@tauri-apps/plugin-hapticsbun add @tauri-apps/plugin-haptics
「haptics」プラグインは JavaScript で利用できます。
import { vibrate, impactFeedback, notificationFeedback, selectionFeedback,} from '@tauri-apps/plugin-haptics';
await vibrate(1);await impactFeedback('medium');await notificationFeedback('warning');await selectionFeedback();デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、capabilities 設定でアクセス権限を変更する必要があります。
詳細については「セキュリティ・レベル Capabilities」の章を参照してください。また、プラグインのアクセス権限を設定するには「プライグン・アクセス権の使用」の章のステップ・バイ・ステップ・ガイドを参照してください。
{ "$schema": "../gen/schemas/mobile-schema.json", "identifier": "mobile-capability", "windows": ["main"], "platforms": ["iOS", "android"], "permissions": [ "haptics:allow-impact-feedback", "haptics:allow-notification-feedback", "haptics:allow-selection-feedback", "haptics:allow-vibrate" ]}Permission Table
| Identifier | Description |
|---|---|
|
|
Enables the impact_feedback command without any pre-configured scope. |
|
|
Denies the impact_feedback command without any pre-configured scope. |
|
|
Enables the notification_feedback command without any pre-configured scope. |
|
|
Denies the notification_feedback command without any pre-configured scope. |
|
|
Enables the selection_feedback command without any pre-configured scope. |
|
|
Denies the selection_feedback command without any pre-configured scope. |
|
|
Enables the vibrate command without any pre-configured scope. |
|
|
Denies the vibrate command without any pre-configured scope. |
【※ この日本語版は、「Nov 19, 2025 英語版」に基づいています】
© 2025 Tauri Contributors. CC-BY / MIT