Selim Hallaç
29 Mart 2019 · Yazılım · 1 dk okuma

React Native: device vibration

Bu yazı 2019 tarihli ve arşivde. İçindeki kod ve servisler bugün çalışmayabilir.

İlk olarak importla başlıyoruz.

import {View, Text, Vibration} from 'react-native';

const DURATION = 10000 ;

Classın içine
StartVibrationFunction = () => {
    // Titreşimi başlatır.
    Vibration.vibrate(DURATION);
  };

  StopVibrationFunction = () => {
    Titreşimi durdurur.
    Vibration.cancel();
  };

Gelelim render'a ;
 <View style={{margin: 10}}>
     <Button title = "Titreşimi Başlat" onPress = {StartVibrationFunction} />
</View>
<View style={{margin: 10}}>
     <Button title = "Titreşimi Durdur" onPress = {StopVibrationFunction} />
 </View>