Skip to content

Commit 5af9631

Browse files
committed
feat: Expose getCentralManager and getInstance methods
1 parent b19d5b5 commit 5af9631

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ios/BleManager.h

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#ifdef RCT_NEW_ARCH_ENABLED
55

66
#import <BleManagerSpec/BleManagerSpec.h>
7+
@class SwiftBleManager;
78

89
@interface BleManager : NativeBleManagerSpecBase <NativeBleManagerSpec>
910
- (void)emitOnDiscoverPeripheral:(NSDictionary *)value;
@@ -17,6 +18,8 @@
1718
- (void)emitOnDidUpdateNotificationStateFor:(NSDictionary *)value;
1819
- (void)emitOnCompanionPeripheral:(NSDictionary *)value;
1920
- (void)emitOnCompanionFailure:(NSDictionary *)value;
21+
+ (nullable CBCentralManager *)getCentralManager;
22+
+ (nullable SwiftBleManager *)getInstance;
2023
@end
2124

2225
#else

ios/BleManager.mm

+8
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,12 @@ - (void)writeWithoutResponse:(NSString *)peripheralUUID
290290
callback:callback];
291291
}
292292

293+
+ (nullable CBCentralManager *)getCentralManager {
294+
return [SwiftBleManager getCentralManager];
295+
}
296+
297+
+ (nullable SwiftBleManager *)getInstance {
298+
return [SwiftBleManager getInstance];
299+
}
300+
293301
@end

ios/SwiftBleManager.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1178,11 +1178,11 @@ import CoreBluetooth
11781178
}
11791179

11801180

1181-
static func getCentralManager() -> CBCentralManager? {
1181+
@objc public static func getCentralManager() -> CBCentralManager? {
11821182
return sharedManager
11831183
}
11841184

1185-
static func getInstance() -> SwiftBleManager? {
1185+
@objc public static func getInstance() -> SwiftBleManager? {
11861186
return shared
11871187
}
11881188

0 commit comments

Comments
 (0)