The Vibration API is exposed at Vibration.vibrate().
The vibration is asynchronous so this method will return immediately.
There will be no effect on devices that do not support Vibration, eg. the simulator.
Note for android
add <uses-permission android:name="android.permission.VIBRATE"/> to AndroidManifest.xml
Vibration patterns are currently unsupported.
Methods #
static vibrate(duration: number) #
'use strict';
var React = require('react-native');
var {
StyleSheet,
View,
Text,
TouchableHighlight,
Vibration,
} = React;
exports.framework = 'React';
exports.title = 'Vibration';
exports.description = 'Vibration API';
exports.examples = [{
title: 'Vibration.vibrate()',
render() {
return (
<TouchableHighlight
style={styles.wrapper}
onPress={() => Vibration.vibrate()}>
<View style={styles.button}>
<Text>Vibrate</Text>
</View>
</TouchableHighlight>
);
},
}];
var styles = StyleSheet.create({
wrapper: {
borderRadius: 5,
marginBottom: 5,
},
button: {
backgroundColor: '#eeeeee',
padding: 10,
},
});