-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from netguru/delay-bluetooth-authorization-popup
Delay iOS Bluetooth authorisation popup
- Loading branch information
Showing
8 changed files
with
129 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Framework/Source Files/Model/BluetoothAuthorizationStatus.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// Copyright © 2018 Netguru Sp. z o.o. All rights reserved. | ||
// Licensed under the MIT License. | ||
// | ||
|
||
import CoreBluetooth | ||
|
||
/// The current authorization state of a Core Bluetooth manager. | ||
@objc public enum BluetoothAuthorizationStatus: Int { | ||
/// Bluetooth authorization status is not determined. | ||
case notDetermined = 0 | ||
|
||
/// Bluetooth connection is restricted. | ||
case restricted = 1 | ||
|
||
/// Bluetooth connection is denied. | ||
case denied = 2 | ||
|
||
/// Bluetooth connection is allowed always. | ||
case allowedAlways = 3 | ||
} | ||
|
||
@available(iOSApplicationExtension 13.0, *) | ||
extension BluetoothAuthorizationStatus { | ||
|
||
/// `CBManagerAuthorization` representation of current authorization status. | ||
var cbManagerAuthorization: CBManagerAuthorization { | ||
switch self { | ||
case .notDetermined: | ||
return .notDetermined | ||
case .restricted: | ||
return .restricted | ||
case .denied: | ||
return .denied | ||
case .allowedAlways: | ||
return .allowedAlways | ||
} | ||
} | ||
} | ||
|
||
@available(iOSApplicationExtension 13.0, *) | ||
extension CBManagerAuthorization { | ||
|
||
/// `BluetoothAuthorizationStatus` representation of current authorization status. | ||
var bluetoothAuthorizationStatus: BluetoothAuthorizationStatus { | ||
switch self { | ||
case .notDetermined: | ||
return .notDetermined | ||
case .restricted: | ||
return .restricted | ||
case .denied: | ||
return .denied | ||
case .allowedAlways: | ||
return .allowedAlways | ||
@unknown default: | ||
return .notDetermined | ||
} | ||
} | ||
} | ||
|
||
extension BluetoothAuthorizationStatus: CustomStringConvertible { | ||
|
||
/// SeeAlso: `CustomStringConvertible.description` | ||
public var description: String { | ||
switch self { | ||
case .notDetermined: | ||
return "notDetermined" | ||
case .restricted: | ||
return "restricted" | ||
case .denied: | ||
return "denied" | ||
case .allowedAlways: | ||
return "allowedAlways" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters