Skip to content

Commit 217b2e3

Browse files
Merge pull request #285 from Polidea/fix/stop_scan_only_when_powered_on
API MISUSE fix
2 parents b3be513 + c0d306e commit 217b2e3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Source/CentralManager.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ public class CentralManager: ManagerType {
163163
return Disposables.create { [weak self] in
164164
guard let strongSelf = self else { return }
165165
// When disposed, stop scan and dispose scanning
166-
strongSelf.manager.stopScan()
166+
if strongSelf.state == .poweredOn {
167+
strongSelf.manager.stopScan()
168+
}
167169
do { strongSelf.lock.lock(); defer { strongSelf.lock.unlock() }
168170
strongSelf.scanDisposable?.dispose()
169171
strongSelf.scanDisposable = nil

0 commit comments

Comments
 (0)