1.0.1 • Published 4 years ago

@uni/vibrate v1.0.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
4 years ago

vibrate

npm

Make the phone vibrate

Supported

Install

$ npm install @uni/vibrate --save

or

$ npm install @uni/apis --save

Usage

import { vibrateShort } from '@uni/vibrate';

vibrateLong({
  success (){
    console.log('success');
  }
});

// promise
vibrateLong().then(() => {
  console.log('success');
});
vibrateShort({
  success (){
    console.log('success');
  }
});

// promise
vibrateShort().then(() => {
  console.log('success');
});

You can also import from the big package:

import { vibrate } from '@uni/apis';

vibrate.vibrateLong().then(() => {
  console.log('success');
});
vibrate.vibrateShort().then(() => {
  console.log('success');
});

方法

vibrateShort

Allows the phone to vibrate for a short period of time (15 ms). This only works on iPhone 7/7 Plus and Android models.

Arguments

PropertyTypeDescriptionrequiredDefault
optionsobject ✔️-
options.successFunction The callback function for a successful API call-
options.failFunction The callback function for a failed API call-
options.completeFunction The callback function used when the API call completed (always executed whether the call succeeds or fails)-

Non-universal parameters (due to destroying the ability of one code and multiple terminals, it is not recommended to use)

PropertyTypeDescriptionrequiredDefaultSupported
optionsobject ✔️--
options.typestring Vibration intensity type, valid values ​​are: heavy, medium, light-

vibrateLong

Allows the phone to vibrate for a long period of time (400 ms).

Arguments

PropertyTypeDescriptionrequiredDefault
optionsobject ✔️-
options.successFunction The callback function for a successful API call-
options.failFunction The callback function for a failed API call-
options.completeFunction The callback function used when the API call completed (always executed whether the call succeeds or fails)-