![React Native Haptic Patterns - Simform](./assets/react-native-haptic-patterns.png) # react-native-haptic-patterns [![react-native-haptic-patterns on npm](https://img.shields.io/npm/v/react-native-haptic-patterns.svg?style=flat)](https://www.npmjs.com/package/react-native-haptic-patterns) [![react-native-haptic-patterns downloads](https://img.shields.io/npm/dm/react-native-haptic-patterns)](https://www.npmtrends.com/react-native-haptic-patterns) [![react-native-haptic-patterns install size](https://packagephobia.com/badge?p=react-native-haptic-patterns)](https://packagephobia.com/result?p=react-native-haptic-patterns) [![Android](https://img.shields.io/badge/Platform-Android-green?logo=android)](https://www.android.com) [![iOS](https://img.shields.io/badge/Platform-iOS-green?logo=apple)](https://developer.apple.com/ios) [![MIT](https://img.shields.io/badge/License-MIT-green)](https://opensource.org/licenses/MIT) A React Native library for creating and playing customizable haptic feedback patterns on iOS and Android. Supports advanced pattern recording and playback, enabling developers to deliver rich, tactile experiences in their mobile applications. --- ## ✨ Features - ✅ **Cross-platform support** - Works seamlessly on both iOS and Android - ✅ **Custom haptic patterns** - Create your own vibration patterns with precise control - ✅ **Pattern recording & playback** - Record and replay complex haptic sequences - ✅ **Core Haptics API** - Leverage iOS's advanced haptic engine (iOS 13+) - ✅ **TypeScript support** - Full type definitions included - ✅ **Simple API** - Easy-to-use methods with Promise-based interface - ✅ **Lightweight** - Minimal dependencies and small bundle size --- ## Quick Access [Features](#-features) | [Requirements](#requirements) | [Installation](#installation) | [Usage](#usage) | [Methods](#methods) | [Types](#types) | [Examples](#examples) | [Troubleshooting](#troubleshooting) | [License](#license) --- ## Requirements - **React Native** >= 0.70.0 - **iOS** >= 13.0 (for Core Haptics support) - **Android** API >= 29 (Android 9.0+) ### Permissions #### Android Add the following permission to your `android/app/src/main/AndroidManifest.xml`: ```xml ``` --- ## Getting Started Here's how to get started with `react-native-haptic-patterns` in your React Native project: ### Installation **1. Install the package** ```sh npm install react-native-haptic-patterns ``` Or using Yarn: ```sh yarn add react-native-haptic-patterns ``` **2. Install iOS dependencies** ```sh cd ios && pod install && cd .. ``` Or using npx: ```sh npx pod-install ``` **3. Configure Android permissions** Add the vibration permission to `android/app/src/main/AndroidManifest.xml`: ```xml ``` ## Usage ### Basic Example Import and use the library in your React Native app: ```tsx import React from 'react'; import { Button, View } from 'react-native'; import { HapticPatterns } from 'react-native-haptic-patterns'; const MyComponent = () => { const handlePress = async () => { try { // Check if device supports haptics const isSupported = await HapticPatterns.checkForHapticSupport(); if (isSupported) { // Play a 200ms haptic pattern HapticPatterns.playHapticPattern(200); } else { console.log('Haptics not supported on this device'); } } catch (error) { console.error('Haptic error:', error); } }; return (