UNPKG

react-native-haptic-feedback

Version:
32 lines (31 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.playHaptic = playHaptic; var _reactNative = require("react-native"); var _hapticFeedback = _interopRequireDefault(require("../hapticFeedback")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } /** * Cross-platform haptic file playback. * * - **iOS**: plays the given `.ahap` file via Core Haptics (`playAHAP`). * Place `.ahap` files in `<bundle>/haptics/` or the bundle root. * - **Android**: AHAP is an Apple-only format. The `fallback` pattern is * played via `triggerPattern` instead. * * This is the recommended cross-platform alternative to the iOS-only `playAHAP`. * * @example * import { playHaptic, pattern } from 'react-native-haptic-feedback'; * * await playHaptic('my-effect.ahap', pattern('oO.O')); */ async function playHaptic(ahapFile, fallback, options) { if (!_hapticFeedback.default.isEnabled()) return; if (_reactNative.Platform.OS === "ios") { return _hapticFeedback.default.playAHAP(ahapFile); } return _hapticFeedback.default.triggerPattern(fallback, options); } //# sourceMappingURL=playHaptic.js.map