import DeviceInfo, { PowerState } from 'react-native-device-info'; import ReactNativeHapticFeedback from 'react-native-haptic-feedback'; // Define a const enum for HapticFeedbackTypes export const enum HapticFeedbackTypes { ImpactLight = 'impactLight', ImpactMedium = 'impactMedium', ImpactHeavy = 'impactHeavy', Selection = 'selection', NotificationSuccess = 'notificationSuccess', NotificationWarning = 'notificationWarning', NotificationError = 'notificationError', } const triggerHapticFeedback = (type: HapticFeedbackTypes) => { DeviceInfo.getPowerState().then((state: Partial) => { if (!state.lowPowerMode) { ReactNativeHapticFeedback.trigger(type, { ignoreAndroidSystemSettings: false, enableVibrateFallback: true }); } else { console.log('Haptic feedback not triggered due to low power mode.'); } }); }; export default triggerHapticFeedback;