react-native-ble-manager 8.0.2 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/ios/BleManager.m +12 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ The library support the react native autolink feature.
|
|
|
43
43
|
|
|
44
44
|
<!-- Only when targeting Android 12 or higher -->
|
|
45
45
|
<!-- Please make sure you read the following documentation to have a
|
|
46
|
-
better
|
|
46
|
+
better understanding of the new permissions.
|
|
47
47
|
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location
|
|
48
48
|
-->
|
|
49
49
|
|
|
@@ -780,6 +780,8 @@ A peripheral was disconnected.
|
|
|
780
780
|
|
|
781
781
|
- `peripheral` - `String` - the id of the peripheral
|
|
782
782
|
- `status` - `Number` - [Android only] disconnect [`reasons`](<https://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onConnectionStateChange(android.bluetooth.BluetoothGatt,%20int,%20int)>)
|
|
783
|
+
- `domain` - `String` - [iOS only] disconnect error domain
|
|
784
|
+
- `code` - `Number` - [iOS only] disconnect error code (<https://developer.apple.com/documentation/corebluetooth/cberror/code>)
|
|
783
785
|
|
|
784
786
|
### BleManagerPeripheralDidBond
|
|
785
787
|
|
|
@@ -802,3 +804,15 @@ _For more on performing long-term bluetooth actions in the background:_
|
|
|
802
804
|
[iOS Bluetooth State Preservation and Restoration](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW10)
|
|
803
805
|
|
|
804
806
|
[iOS Relaunch Conditions](https://developer.apple.com/library/archive/qa/qa1962/_index.html)
|
|
807
|
+
|
|
808
|
+
### BleManagerDidUpdateNotificationStateFor [iOS only]
|
|
809
|
+
|
|
810
|
+
The peripheral received a request to start or stop providing notifications for a specified characteristic's value.
|
|
811
|
+
|
|
812
|
+
**Arguments**
|
|
813
|
+
|
|
814
|
+
- `peripheral` - `String` - the id of the peripheral
|
|
815
|
+
- `characteristic` - `String` - the UUID of the characteristic
|
|
816
|
+
- `isNotifying` - `Boolean` - Is the characteristic notifying or not
|
|
817
|
+
- `domain` - `String` - [iOS only] error domain
|
|
818
|
+
- `code` - `Number` - [iOS only] error code
|
package/ios/BleManager.m
CHANGED
|
@@ -76,7 +76,7 @@ bool hasListeners;
|
|
|
76
76
|
|
|
77
77
|
- (NSArray<NSString *> *)supportedEvents
|
|
78
78
|
{
|
|
79
|
-
return @[@"BleManagerDidUpdateValueForCharacteristic", @"BleManagerStopScan", @"BleManagerDiscoverPeripheral", @"BleManagerConnectPeripheral", @"BleManagerDisconnectPeripheral", @"BleManagerDidUpdateState", @"BleManagerCentralManagerWillRestoreState"];
|
|
79
|
+
return @[@"BleManagerDidUpdateValueForCharacteristic", @"BleManagerStopScan", @"BleManagerDiscoverPeripheral", @"BleManagerConnectPeripheral", @"BleManagerDisconnectPeripheral", @"BleManagerDidUpdateState", @"BleManagerCentralManagerWillRestoreState", @"BleManagerDidUpdateNotificationStateFor"];
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
|
|
@@ -110,6 +110,9 @@ bool hasListeners;
|
|
|
110
110
|
if (characteristic == nil){
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
|
+
if (hasListeners) {
|
|
114
|
+
[self sendEventWithName:@"BleManagerDidUpdateNotificationStateFor" body:@{@"peripheral": peripheral.uuidAsString, @"characteristic": characteristic.UUID.UUIDString, @"isNotifying": @(false), @"domain": [error domain], @"code": @(error.code)}];
|
|
115
|
+
}
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
NSString *key = [self keyForPeripheral: peripheral andCharacteristic:characteristic];
|
|
@@ -138,6 +141,9 @@ bool hasListeners;
|
|
|
138
141
|
[stopNotificationCallbacks removeObjectForKey:key];
|
|
139
142
|
}
|
|
140
143
|
}
|
|
144
|
+
if (hasListeners) {
|
|
145
|
+
[self sendEventWithName:@"BleManagerDidUpdateNotificationStateFor" body:@{@"peripheral": peripheral.uuidAsString, @"characteristic": characteristic.UUID.UUIDString, @"isNotifying": @(characteristic.isNotifying)}];
|
|
146
|
+
}
|
|
141
147
|
}
|
|
142
148
|
|
|
143
149
|
|
|
@@ -860,7 +866,11 @@ RCT_EXPORT_METHOD(requestMTU:(NSString *)deviceUUID mtu:(NSInteger)mtu callback:
|
|
|
860
866
|
}
|
|
861
867
|
|
|
862
868
|
if (hasListeners) {
|
|
863
|
-
|
|
869
|
+
if (error) {
|
|
870
|
+
[self sendEventWithName:@"BleManagerDisconnectPeripheral" body:@{@"peripheral": [peripheral uuidAsString], @"domain": [error domain], @"code": @(error.code)}];
|
|
871
|
+
} else {
|
|
872
|
+
[self sendEventWithName:@"BleManagerDisconnectPeripheral" body:@{@"peripheral": [peripheral uuidAsString]}];
|
|
873
|
+
}
|
|
864
874
|
}
|
|
865
875
|
}
|
|
866
876
|
|