Skip to content

Commit a9652af

Browse files
authored
Merge pull request #106 from kennylovrin/wrap-restored-peripherals
wrap CBPeripherals as CBMPeripheralNative on restore
2 parents 581811c + beafc8e commit a9652af

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CoreBluetoothMock/CBMCentralManagerNative.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ public class CBMCentralManagerNative: CBMCentralManager {
131131

132132
func centralManager(_ central: CBCentralManager,
133133
willRestoreState dict: [String : Any]) {
134-
manager.delegate?.centralManager(manager, willRestoreState: dict)
134+
var state = dict
135+
136+
if let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] {
137+
state[CBMCentralManagerRestoredStatePeripheralsKey] = peripherals.map {
138+
CBMPeripheralNative($0)
139+
}
140+
}
141+
142+
manager.delegate?.centralManager(manager, willRestoreState: state)
135143
}
136144
}
137145

0 commit comments

Comments
 (0)