Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29459

Android device doesn't vibrate when calling Vibration.vibrate() in HeadlessJS function

$
0
0

I am successfully using Vibration.vibrate([1000, 2000], true); inside a component in a React Native Android app - the device vibrates when this is called.

However I am also using HeadlessJS to launch a notification when the app is in the background or killed:

App.js:

import backgroundNotificationHandler from './src/services/backgroundNotificationListener';...AppRegistry.registerComponent(appName, () => App);firebase.messaging().setBackgroundMessageHandler(backgroundNotificationHandler);

backgroundNotificationListener.js:

import { NativeModules, Vibration } from 'react-native';import { parseTimeStringForNotification } from './parseTime'import InCallManager from 'react-native-incall-manager';const backgroundNotificationHandler = async message => {  console.log(Vibration); // logs the Vibration object  InCallManager.startRingtone('_BUNDLE_'); // this works  Vibration.vibrate([1000, 2000], true); // this doesn't work...

Is there any reason this shouldn't work? Is there some kind of OS restriction on this / should I try a third party package here to make the device vibrate?


Viewing all articles
Browse latest Browse all 29459

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>