コンテンツにスキップ
Tauri

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 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」の章を参照してください。また、プラグインのアクセス権限を設定するには「プライグン・アクセス権の使用」の章のステップ・バイ・ステップ・ガイドを参照してください。

src-tauri/capabilities/mobile.json
{
"$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

haptics:allow-impact-feedback

Enables the impact_feedback command without any pre-configured scope.

haptics:deny-impact-feedback

Denies the impact_feedback command without any pre-configured scope.

haptics:allow-notification-feedback

Enables the notification_feedback command without any pre-configured scope.

haptics:deny-notification-feedback

Denies the notification_feedback command without any pre-configured scope.

haptics:allow-selection-feedback

Enables the selection_feedback command without any pre-configured scope.

haptics:deny-selection-feedback

Denies the selection_feedback command without any pre-configured scope.

haptics:allow-vibrate

Enables the vibrate command without any pre-configured scope.

haptics:deny-vibrate

Denies the vibrate command without any pre-configured scope.

【※ この日本語版は、「Nov 19, 2025 英語版」に基づいています】


© 2025 Tauri Contributors. CC-BY / MIT