desc
npm install react-native-ble-ios-sdtA React Native library for scanning Bluetooth Low Energy (BLE) peripherals on IOS.
1. Install the library:
``bash`
npm install react-native-ble-ios-sdt
npx pod-install ios
2. Link the native modules (if React Native version < 0.60):
`bash`
react-native link react-native-ble-ios-sdt
3. Handle Permissions:
Ensure you have the necessary permissions configured in your Info.plist for iOS.
`xml`
``javascript
import React from 'react';
import { View, Button, FlatList, Text } from 'react-native';
import { BLEModule } from 'react-native-ble-ios-sdt';
type Peripheral = {
id: string;
name: string;
rssi: number;
advertisementData: any;
};
const App = () => {
const [peripherals, setPeripherals] = useState
const handleScan = () => {
BLEManager.startScan((results) => {
setPeripherals(results);
});
};
const handleStop = () => {
BLEManager.stopScan();
};
return (
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
)}
/>
);
};
export default App;