> For the complete documentation index, see [llms.txt](https://ja.docs.monaca.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ja.docs.monaca.io/reference/core-cordova-plugins/cordova-12.0/vibration-puraguin.md).

# Vibration プラグイン

グローバルスコープに属していますが、使用できるのは、`deviceready` イベントの発火後になります。

このプラグインの詳細は、 [こちらの原文 ( GitHub )](https://github.com/apache/cordova-plugin-vibration) をご確認ください。

```javascript
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.vibrate);
}
```

## プラグイン ID

```javascript
cordova-plugin-vibration
```

## プラグインの追加方法

このプラグインを使用する場合には、Monaca クラウド IDE の \[ Cordova プラグインの管理 ] 上で、`Vibration` プラグインを[有効](/products_guide/monaca_ide/dependencies/cordova_plugin.md#cordova-puraguin-noinpto)にします。

{% hint style="info" %}
`navigator.notification.vibrateWithPattern` と `navigator.notification.cancelVibration` は、iOSでは動作しません。
{% endhint %}

## API の解説

### vibrate

この関数は、引き渡すパラメーターに応じて、動作 ( pattern/パターン ) が異なります。on、on/off、off の 3 つのパターンがあります。

### 基本的な振動処理

指定した時間の長さで、端末を振動させます。

```javascript
    navigator.vibrate(time)
```

または、

```javascript
    navigator.vibrate([time])
```

* **time**: 振動する時間 ( ミリ秒単位 ) です。 *( 数値 )*

#### 例

```javascript
    // Vibrate for 3 seconds
    navigator.vibrate(3000);

    // Vibrate for 3 seconds
    navigator.vibrate([3000]);
```

#### iOS 特有の動作

* **time**: 指定された時間を無視して、代わりに、システム側の設定を使用して振動させます。

```javascript
navigator.vibrate(3000); // 3000 is ignored
```

### pattern ( パターン ) を使用した振動処理 ( Android のみ )

指定された pattern に応じて、端末を振動させます。

```javascript
    navigator.vibrate(pattern);
```

* **pattern**: 振動をオフ・オンにする時間 ( ミリ秒単位 )の組み合わせです。 *( 数値の配列 )*

#### 例

```javascript
    // Vibrate for 1 second
    // Wait for 1 second
    // Vibrate for 3 seconds
    // Wait for 1 second
    // Vibrate for 5 seconds
    navigator.vibrate([1000, 1000, 3000, 1000, 5000]);
```

### 振動の停止処理 ( iOS ではサポートされていません )

振動を即時に停止します。

```javascript
    navigator.vibrate(0)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ja.docs.monaca.io/reference/core-cordova-plugins/cordova-12.0/vibration-puraguin.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
