@@ -16,6 +16,10 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
| ohos.vibrator | startVibration(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback<void>): void | Starts vibration with the specified effect and attribute. This API uses an asynchronous callback to return the result.|
| ohos.vibrator | stopVibration(stopMode: VibratorStopMode): Promise<void> | Stops vibration in the specified mode. This API uses a promise to return the result. |
| ohos.vibrator | stopVibration(stopMode: VibratorStopMode, callback: AsyncCallback<void>): void | Stops vibration in the specified mode. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | stopVibration(): Promise<void> | Stops vibration in all modes. This API uses a promise to return the result. |
| ohos.vibrator | stopVibration(callback: AsyncCallback<void>): void | Stops vibration in all modes. This API uses an asynchronous callback to return the result. |
| ohos.vibrator | isSupportEffect(effectId: string): Promise<boolean> | Checks whether the passed effect ID is supported. This API uses a promise to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
| ohos.vibrator | isSupportEffect(effectId: string, callback: AsyncCallback<boolean>): void | Checks whether the passed effect ID is supported. This API uses an asynchronous callback to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
## How to Develop
...
...
@@ -27,7 +31,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js
importvibratorfrom'@ohos.vibrator';
try{
vibrator.startVibration({
vibrator.startVibration({// To use startVibration, you must configure the ohos.permission.VIBRATE permission.
type:'time',
duration:1000,
},{
...
...
@@ -50,7 +54,7 @@ For details about the APIs, see [Vibrator](../reference/apis/js-apis-vibrator.md
```js
importvibratorfrom'@ohos.vibrator';
try{
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode.
// Stop vibration in VIBRATOR_STOP_MODE_TIME mode. To use stopVibration, you must configure the ohos.permission.VIBRATE permission.
| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the vibration stops, **err** is **undefined**; otherwise, **err** is an error object.|
| callback | AsyncCallback<boolean> | Yes | Callback used to return the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
**Example**
```js
importvibratorfrom'@ohos.vibrator';
try{
// Check whether 'haptic.clock.timer' is supported.
| Promise<boolean> | Promise that returns the result. The value **true** means that the passed effect ID is supported, and **false** means the opposite. |
**Example**
```js
importvibratorfrom'@ohos.vibrator';
try{
// Check whether 'haptic.clock.timer' is supported.
Applications developed based on OpenHarmony4.0.5.2 or a later SDK version can use **isSupportEffect** to check whether the passed effect ID is supported.
**Key API/Component Changes**
The **isSupportEffect** API is added in **@ohos.vibrator.d.ts**.