一组可重用的库、服务和组件,用于 Swift iOS 应用。
目录
BrivoSDK 可以使用 Swift Package Manager 进行使用。 您可以在 Swift Package Index 上找到它:https://swiftpackageindex.cn/brivo-mobile-team/brivo-mobile-sdk-ios。 您也可以在 Github 上找到它:https://github.com/brivo-mobile-team/brivo-mobile-sdk-ios。 为了添加 BrivoSDK,您需要执行以下操作
1. Go to the Xcode project section for Package Dependencies
2. Click the "+" button
3. Enter in the search field called "Search or Enter Package URL" this url: https://github.com/brivo-mobile-team/brivo-mobile-sdk-ios.git
4. Select Add Package and add it to the needed target
1. Go to the manifest file
2. Add the reference to the BrivoSDK:
- if the main branch is needed use this: .package(url: "https://github.com/brivo-mobile-team/brivo-mobile-sdk-ios.git", branch: "main")
- if a specific version is needed use this: .package(url: "https://github.com/brivo-mobile-team/brivo-mobile-sdk-ios.git", from: "1.22.1")
3. Select a product using this: .product(name: "BrivoMobileSDK", package: "brivo-mobile-sdk-ios")
BrivoSDK 组件是使用目标版本 iOS 14.0 构建的,所需的 Apple Swift 版本为 5,Xcode 版本为 15.4
要使用此框架,您需要访问 https://github.com/Allegion-Plc/AllegionCocoaPods 以获取 AllegionSDK。 涉及两个步骤
此存储库在 BrivoSampleApp 文件夹中带有一个示例项目。 在这里,我们展示了如何使用 SPM 并获取我们 SDK 的主分支来使用该 SDK。
在使用 Brivo Mobile SDK 之前,必须使用 BrivoSDKConfiguration
对象配置(通过实例)BrivoSDK
类。BrivoSDKConfiguration
对象需要以下列出的参数集
/**
Defines the configuration object needed by the BrivoSDK in order to function properly.
- Parameter clientId: Brivo client id
- Parameter clientSecret: Brivo Client secret
- Parameter useSDKStorage: if the SDK should use internal storage for the passes
- Parameter region: the region where the SDK base urls should point in the case apiUrl or authUrl are not provided.
Defaults to Region.us
- Parameter shouldPromptForContinuation: if the SDK should promt for continuation
- Parameter authUrl:the Brivo authentication server base url
- Parameter apiUrl:the Brivo OnAir API base url
- Parameter smartHomeUrl: the Brivo Smart Home base url
- Parameter refreshTokenDelegate: a refresh token delegate that can handle token refresh in case of a HTTP 401 unauthorised
- Parameter sessionRequestTimeout: the HTTP session request timeout
*/
do {
let brivoConfiguration = try BrivoSDKConfiguration(
clientId: "CLIENT_ID",
clientSecret: "CLIENT_SECRET",
useSDKStorage: true/false,
region: true/false)
BrivoSDK.instance.configure(brivoConfiguration: brivoConfiguration)
} catch let error {
// Handle BrivoSDK configuration exception
}
如果 BrivoSDKConfiguration 类未正确初始化,则会引发异常。 例如,其中一个参数为 nil 或空字符串。
此模块实现了可以通过“instance”属性访问的 BrivoSDK 类。 它具有以下界面
/**
Configure the Brivo SDK.
- Parameter brivoConfiguration: Brivo configuration.
*/
func configure(brivoConfiguration: BrivoSDKConfiguration)
/**
Returns the Brivo SDK configuration.
*/
func getBrivoConfiguration() throws -> BrivoSDKConfiguration
/**
Returns the device ID.
It also persists the device ID first time it is returned so that succesive calls get the same value.
*/
func getDeviceId() -> String
此模块管理应用程序和 Brivo 环境之间的连接。 它具有以下界面
//**
Authenticate using a Brivo Onair Account.
- Parameter credential: Credentials used to authenticate in Brivo Onair
- Returns: Result with (BrivoTokens?, BrivoOnAirResponseStatus?) or BrivoError
*/
func authenticate(credential: BrivoOnAirCredentials) async -> Result<(BrivoTokens?, BrivoOnAirResponseStatus?), BrivoError>
/**
Redeem a Brivo Onair Pass. Brivo Onair Pass allows you to open doors with your smartphone.
- Parameter passId: Email received from Brivo
- Parameter passCode: Token received from Brivo
- Returns: Result with BrivoOnairPass? or BrivoError
*/
func redeemPass(passId: String,
passCode: String) async -> Result<BrivoOnairPass?, BrivoError>
/**
Refresh a Brivo Onair Pass. Brivo Onair Pass allows you to open doors with your smartphone.
- Parameter brivoTokens: accessToken received from Brivo
- Returns: Result with BrivoOnairPass? or BrivoError
*/
func refreshPass(brivoTokens: BrivoTokens) async -> Result<BrivoOnairPass?, BrivoError>
/**
Sends a request to unlock an access-point.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
This method should be used when handing the credentials outside of the SDK
- Parameter tokens: Access Token received from Brivo
- Parameter passId : Brivo passId
- Parameter accessPointId: The id associated with the accesspoint
- Returns: AsyncThrowingStream with BrivoResult or BrivoError
*/
func unlockAccessPoint(tokens: BrivoTokens?,
passId: String,
accessPointId: String,
accessPointPath: AccessPointPath?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Sends a request to unlock an access-point.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
This method should be used when handing the credentials outside of the SDK
- Parameter passId: Brivo passId
- Parameter accessPointId: The id associated with the accesspoint
- Returns: Result with BrivoResult or BrivoError
*/
func unlockAccessPoint(passId: String,
accessPointId: String) async -> Result<BrivoResult, BrivoError>
/**
Retrieve SDK locally stored passes
- Returns: Result with [BrivoOnairPass] or BrivoError
*/
func retrieveSDKLocallyStoredPasses() async -> Result<[BrivoOnairPass], BrivoError>
/**
Sends a request to unlock an access-point that is using a third party lock.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointId: The id associated with the accesspoint
- Parameter body: BrivoControlLockUnlockStatusRequestBody:
unlockStatus;
providerTypeId;
deviceModelId;
- Returns: Result with String? or BrivoError
*/
func controlLockUnlock(tokens: BrivoTokens,
accessPointId: String,
body: BrivoControlLockUnlockRequestBody) async -> Result<String?, BrivoError>
/**
Sends a request to specify the response status of the previous unlock access-point request that is using a third party lock.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointId: The id associated with the accesspoint
- Parameter body: BrivoControlLockUnlockStatusRequestBody:
unlockStatus;
providerTypeId;
deviceModelId;
- Returns: Result with String? or BrivoError
*/
func controlLockUnlockStatus(tokens: BrivoTokens,
accessPointId: String,
body: BrivoControlLockUnlockStatusRequestBody) async -> Result<String?, BrivoError>
/**
Sends a request to get all the sites from OnAir
The request will be granted if the tokens are valid
- Parameter tokens: Access Token received from Brivo
- Parameter siteName: value for retrieving by site name
- Returns: Result with [BrivoSite] or BrivoError
*/
func retrieveSites(tokens: BrivoTokens,
siteName: String?) async -> Result<[BrivoSite], BrivoError>
/**
Sends a request to get details about a site from OnAir
The request will be granted if the tokens are valid
- Parameter tokens: Access Token received from Brivo
- Parameter siteId: The id of the site, can be obtained from retrieveSites request
- Returns: Result with BrivoSite or BrivoError
*/
func retrieveSiteDetails(tokens: BrivoTokens,
siteId: Int) async -> Result<BrivoSite, BrivoError>
/**
Sends a request to get all the access points from a site
The request will be granted if the tokens are valid
- Parameter tokens: Access Token received from Brivo
- Parameter siteId: The id of the site, can be obtained from retrieveSites request
- Parameter accessPointName: The name of the accessPoint used to filter the accessPoints list
- Returns: Result with [BrivoAccessPoint] or BrivoError
*/
func retrieveSiteAccessPoints(tokens: BrivoTokens,
siteId: Int,
accessPointName: String?) async -> Result<[BrivoAccessPoint], BrivoError>
/**
Sends a request to get details about an access point
The request will be granted if the tokens are valid
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointId: The id of the access point, can be obtained from retrieveSiteAccessPoints request
- Returns: Result with BrivoAccessPoint or BrivoError
*/
func retrieveAccessPointDetails(tokens: BrivoTokens,
accessPointId: Int) async -> Result<BrivoAccessPoint, BrivoError>
/**
Sends a request to unlock an access-point that is using a third party lock.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointId : The id associated with the accesspoint
- Parameter body: BrivoControlLockConfigRequestBody:
{
"db": {
"usrRcrd": {
"deleteAll": 1,
"delete": [],
"update": [],
"add": []
},
"schedules": [
{
"days": [
"Mo",
"Tu",
"We",
"Th",
"Fr",
"Sa",
"Su"
],
"lngth": 1439,
"strtHr": 0,
"strtMn": 0
}
]
}
}
- Returns: Result with String? or BrivoError
*/
func controlLockConfig(tokens: BrivoTokens,
accessPointId: String,
body: BrivoControlLockConfigRequestBody) async -> Result<String?, BrivoError>
/**
Sends a request to specify the response status of the previous config access-point request that is using a third party lock.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointId : The id associated with the accesspoint
- Parameter controlLockConfigSave : The payload that was received from control lock config + the first fragment in the encrypedConfig field
- Returns: Result with String? or BrivoError
*/
func controlLockConfigSave(tokens: BrivoTokens,
accessPointId: String,
controlLockConfigSaveResponse: BrivoControlLockConfigSaveResponse) async -> Result<String?, BrivoError>
/**
Sends a request to get the current administrator
The on success call will provide the administrator information
- Parameter tokens: Access Token received from Brivo
- Returns: Result with BrivoOnAirAdministrator? or BrivoError
*/
func getCurrentAdministrator(tokens: BrivoTokens) async -> Result<BrivoOnAirAdministrator?, BrivoError>
/**
Retrieve the list of reader commands
The on success call will provide the reader commands
- Parameter tokens: Access Token received from Brivo
- Parameter accessPointIds: An array which contains the access point id's for which to fetch the reader commands
- Returns: Result with [BrivoReaderCommand] or BrivoError
*/
func getReaderCommands(tokens: BrivoTokens,
accessPointIds: [String]) async -> Result<[BrivoReaderCommand], BrivoError>
/**
Engage reader command
The on success call will provide the reader commands
- Parameter tokens: Access Token received from Brivo
- Parameter readerId : The id associated with the reader command
- Parameter passId : Brivo passId
- Parameter option : The option for the reader command
- Returns: Result with Void or BrivoError
*/
func engageReaderCommand(tokens: BrivoTokens,
readerId: String,
passId: String,
option: String) async -> Result<Void, BrivoError>
/**
Get Allegion SDK Tokens
The on success closure will provide the allegion SDK tokens
- Parameter accessToken: Access Token received from Brivo
- Returns: Result with AllegionSDKTokens or BrivoError
*/
func getAllegionSDKTokens(accessToken: String) async -> Result<AllegionSDKTokens, BrivoError>
/**
Get BLE security config
- Parameter accessToken: Access Token received from Brivo
- Parameter accessToken: deviceUUID provided by Allegion SDK from the Enroll Mobile device response
- Parameter siteId: the siteId
- Returns: Result with BLESecurityConfigResponse or BrivoError
*/
func getBLESecurityConfig(accessToken: String,
deviceUUID: String,
siteId: String) async -> Result<BLESecurityConfigResponse, BrivoError>
用法示例
Task {
let result = try await BrivoSDKOnAir.instance().redeemPass(passId: self.passID,
passCode: self.passCode)
await MainActor.run {
switch result {
case .success:
// handle success
case .failure(let brivoError):
// handle error
}
}
}
Task {
let result = try await BrivoSDKOnAir.instance().refreshPass(brivoTokens: tokens)
await MainActor.run {
switch result {
case .success(let refreshedPass):
// handle success
case .failure(let responseStatus):
// handle error
}
}
}
Task {
let result = try await BrivoSDKOnAir.instance().retrieveSDKLocallyStoredPasses()
await MainActor.run {
switch result {
case .success(let brivoOnAirPasses):
// handle success
case .failure(let brivoError):
// handle error
}
}
}
此模块提供了一个简化的界面,用于解锁蓝牙类型或 Internet 类型的接入点。 它具有以下界面
static func instance() -> BrivoSDKAccess
/**
Unlocks an access-point.
This method should be used when handing the credentials outside of the SDK
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter selectedAccessPoint: BrivoSelectedAccessPoint can be created from BrivoAccessPoint.
The class BrivoSDKOnAirHelper from BrivoOnAir has methods to help with the creation of the object.
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func unlockAccessPoint(selectedAccessPoint: BrivoSelectedAccessPoint,
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Unlocks an access-point.
This method should be used when the SDK handles the credentials.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter passId : Brivo passId
- Parameter accessPointId: The id associated with the accesspoint
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func unlockAccessPoint(passId: String,
accessPointId: String,
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Locks an access-point.
This method should be used when handing the credentials outside of the SDK
Only a few access-points support the locking process.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter selectedAccessPoint: BrivoSelectedAccessPoint can be created from BrivoAccessPoint.
The class BrivoSDKOnAirHelper from BrivoOnAir has methods to help with the creation of the object.
- Parameter cancellationSignal: can be used to cancel the locking process
- Returns: AsyncThrowingStream with BrivoResult or BrivoError
*/
func lockAccessPoint(selectedAccessPoint: BrivoSelectedAccessPoint,
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Locks an access-point.
This method should be used when the SDK handles the credentials.
Only a few access-points support the locking process.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter passId : Brivo passId
- Parameter accessPointId: The id associated with the accesspoint
- Parameter cancellationSignal: can be used to cancel the locking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func lockAccessPoint(passId: String,
accessPointId: String,
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Unlocks the nearest Bluetooth access point from the list of passes.
This method should be used when handing the credentials outside of the SDK
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter passes: A list that contains BrivoOnairPasses from which the access points will be searched
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func unlockNearestBLEAccessPoint(passes: [BrivoOnairPass],
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Unlocks the nearest Bluetooth access point from the list of passes.
This method should be used when handing the credentials outside of the SDK
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter pass: A BrivoOnairPass from which the access points will be searched
- Parameter siteId: The id of the site that will be used to search the access points from
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func unlockNearestBLEAccessPoint(pass: BrivoOnairPass,
siteId: Int,
cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Unlocks the nearest Bluetooth access point from the ones that are currently available.
This method should be used when the SDK handles the credentials.
The request will be granted if the card holder has permission to access this door based on their groups affiliation.
Available only to digital credential users
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Returns: AsyncThrowingStream with BrivoResult or Error
*/
func unlockNearestBLEAccessPoint(cancellationSignal: CancellationSignal?) async -> AsyncThrowingStream<BrivoResult, Error>
/**
Requests external credentials from On Air system.
- Parameter tokens: the brivo tokens
- Parameter accessPointId: the id associated with the accesspoint
- Parameter requestData: the request data
- Returns: Result with String? or BrivoError
*/
func requestExternalCredentialsFromOnAir(tokens: BrivoTokens,
accessPointId: String,
requestData: String) async -> Result<String?, BrivoError>
/**
Turns on the BLE scanning.
*/
func turnOnCentral()
/**
Returns the Bluetooth state..
- Returns: the BLE state
*/
func getBLEState() -> CBManagerState
/**
Notifies using a completion then the BLE state changes.
- Parameter completion: the completion
- Returns: the completion identifier
*/
func onBleChanged(completion: @escaping (CBManagerState) -> Void) -> NSNumber?
/**
Removes a completion handler ID from the completion notifications.
- Parameter id: the completion hadler id
*/
func removeCompletionFor(id: NSNumber)
用法示例
do {
try BrivoSDKAccess.instance().unlockAccessPoint(passId: "PASS_ID",
accessPointId: "ACCESS_POINT_ID",
onResult: { [weak self] (brivoResult) in
//Handle unlock access point success case
}, cancellationSignal: cancellationSignal)
} catch let error {
//Handle BrivoSDK initialization exception
}
do {
let selectedAccessPoint = BrivoSelectedAccessPoint(accessPointId: ...,
userId: ...,
readerUid: ...,
bleCredentials: ...,
timeframe: ...,
passId: ...,
brivoApiTokens: BrivoTokens(...))
try BrivoSDKAccess.instance().unlockAccessPoint(selectedAccessPoint: selectedAccessPoint,
onResult: { [weak self] (brivoResult) in
//Handle unlock access point success case
}, cancellationSignal: cancellationSignal)
} catch let error {
//Handle BrivoSDK initialization exception
}
此模块充当 AllegionSDK 的包装器,并且是 BrivoAccess 解锁 Allegion 设备的 可选依赖项。
注意
使用此模块需要访问 Allegion SDK(请参阅 Podfile)。
Allegion SDK 有一个限制:arm64 架构被排除在外,因此该应用程序只能在带有 Rosetta 的模拟器上运行。
它具有以下界面
/**
Initialise BrivoSDKBLEAllegion
- Parameter configuration: credentials to setup AllegionSDK
*/
init(configuration: BrivoBLEAllegion.BrivoBLEAllegionConfiguration)
/**
Setup initial comunication with AllegionSDK and restores local credentials if possible
- Throws: an error if parameters from ``BrivoBLEAllegionConfiguration`` are rejected by AllegionSDK
*/
func initialise() async throws
/**
Retrieve and store the allegion tokens required for authenticating using AllegionSDK
- Parameter brivoOnAirPass: BrivoOnAir pass
- Note: ``IBrivoSDKBLEAllegion/initialise()`` must be called before.
*/
func refreshCredentials(brivoOnAirPass: BrivoOnAir.BrivoOnairPass) async throws
/**
Unlock access point with allegion door type
- Parameter accessPoint: BrivoSelectedAccessPoint
- Parameter onResult: BrivoResult for unlocking the access point
- Parameter cancellationSignal: can be used to cancel the unlocking process
- Note: ``IBrivoSDKBLEAllegion/initialise()`` must be before.
*/
func unlockAccessPoint(accessPoint: BrivoOnAir.BrivoSelectedAccessPoint, onResult: BrivoCore.OnResultType?, cancellationSignal: BrivoCore.CancellationSignal?)
此模块管理接入点和面板之间通过蓝牙的连接。 与 BLE 通信相关的所有内容都在此处处理。
此模块管理设备上的本地身份验证。 它通过共享的 instance
可用。 它具有以下界面
/**
Cancels an on going authentication process.
*/
func cancelAuthentication()
/**
Checks if a local authentication can be performed.
- Parameter onSuccess: completion block that handles success
- Parameter onFailure: completion block that handles failure
*/
func canAuthenticate(onSucces: OnLocalAuthenticationSuccessType?, onFailure: OnFailureType?)
/**
Performs the local authentication on the device.
- Parameter onSuccess: completion block that handles success
- Parameter onFailure: completion block that handles failure
*/
func authenticate(onSucces: OnLocalAuthenticationSuccessType?, onFailure: OnFailureType?)
此模块管理用于与 Brivo 后端进行 HTTP 通信的主要类。 主要类是
public class HTTPSRequest { ... }
public class BrivoHTTPSRequest: NSObject { ... }
每个模块都通过其完成处理程序返回错误。 所有错误都是 BrivoError。 一些 BrivoError 类型的错误以内联方式发送,如下所示
let brivoError = BrivoError(statusCode: response?.status?.statusCode ?? refreshTokenError.statusCode, errorDescription:
response?.status?.error?.errorDescription ?? refreshTokenError.localizedDescription)
onRefreshTokenFailed?(brivoError)
,其他错误按模块分组,如下面详细介绍
@objc public class BrivoOnAirErrors: NSObject {
@objc public static let serverCallError = BrivoError(statusCode: -3001, errorDescription: "Server call failed.")
@objc public static let authenticationMissingDataError = BrivoError(statusCode: -3002, errorDescription: "Authentication missing data.")
@objc public static let redeemPassMissingDataError = BrivoError(statusCode: -3003, errorDescription: "Redeem pass missing data")
@objc public static let sdkIsNotUsingDefaultStorageError = BrivoError(statusCode: -3004, errorDescription: "SDK is set to not use SDK storage")
@objc public static let getSitesMissingDataError = BrivoError(statusCode: -3005, errorDescription: "Get sites missing data")
@objc public static let getAccessPointsMissingDataError = BrivoError(statusCode: -3006, errorDescription: "Get access points missing data")
@objc public static let controlLockConfigMissingDataError = BrivoError(statusCode: -3007, errorDescription: "Control Lock config missing data")
@objc public static let refreshTokenError = BrivoError(statusCode: HttpStatusCodes.refreshTokenFailed, errorDescription: "Refresh token failed.")
@objc public static func brivoOnAirErrorWithDescription(_ description: String) -> BrivoError {
return BrivoError(statusCode: -3010, errorDescription: description)
}
}
@objc public class BrivoConfigurationErrors: NSObject {
@objc public static let unknownError = BrivoError(statusCode: -1000, errorDescription: "Unknown error.")
@objc public static let notInitializedError = BrivoError(statusCode: -1001, errorDescription: "BrivoSDK init failed. SDK not configured")
@objc public static let notConfiguredForLocalStorageError = BrivoError(statusCode: -1002, errorDescription: "SDK not configured to use local storage")
@objc public static let noPassesFoundInLocalStorageError = BrivoError(statusCode: -1003, errorDescription: "There are no passes on local storage")
@objc public static let accessPointNotFoundInLocalStorageError = BrivoError(statusCode: -1004, errorDescription: "Acess point not found in local storage")
@objc public static let passNotFoundInLocalStorageError = BrivoError(statusCode: -1005, errorDescription: "Pass not found in local storage")
@objc public static let missingBLECredentialError = BrivoError(statusCode: -1006, errorDescription: "Missing ble credential")
@objc public static let accessPointInvalidDoorType = BrivoError(statusCode: -1007, errorDescription: "Access point invalid door type")
@objc public static let missingNetworkConnectionError = BrivoError(statusCode: -1008, errorDescription: "Missing internet connection")
@objc public static func brivoErrorWithDescription(_ description: String) -> BrivoError {
return BrivoError(statusCode: -1010, errorDescription: description)
}
}
@objc public class BrivoLocalAuthenticationErrors: NSObject {
@objc public static let unknownError = BrivoError(statusCode: -4000, errorDescription: "Incorrect Passcode.")
@objc public static let localHardwareUnavailableError = BrivoError(statusCode: -4001, errorDescription: "Hardware unavailable for local authentication")
@objc public static let timeOutError = BrivoError(statusCode: -4002, errorDescription: "Local authentication timed out.")
@objc public static let localHardwareNotPresentError = BrivoError(statusCode: -4003, errorDescription: "Hardware doesn't exist for local authentication")
@objc public static let notEnroledError = BrivoError(statusCode: -4004, errorDescription: "Biometric or passcode verification is required to unlock this door. Please enable one of these security options to continue.")
@objc public static let contextNotSetError = BrivoError(statusCode: -4005, errorDescription: "Context not set for local authentication")
@objc public static let applicationCanceledError = BrivoError(statusCode: -4006, errorDescription: "Authentication was cancelled by application")
@objc public static let notInteractiveError = BrivoError(statusCode: -4007, errorDescription: "Authentication failed because interaction is disabled")
@objc public static let biometryLockoutError = BrivoError(statusCode: -4008, errorDescription: "Biometry is now locked because of too many failed attempts. Passcode is required to unlock biometry")
}
@objc public class BrivoSDKAccessErrors: NSObject {
@objc public static let unknownError = BrivoError(statusCode: -1000, errorDescription: "Unknown error.")
@objc public static let notInitializedError = BrivoError(statusCode: -1001, errorDescription: "BrivoSDK init failed. SDK not configured")
@objc public static let notConfiguredForLocalStorageError = BrivoError(statusCode: -1002, errorDescription: "SDK not configured to use local storage")
@objc public static let noPassesFoundInLocalStorageError = BrivoError(statusCode: -1003, errorDescription: "There are no passes on local storage")
@objc public static let accessPointNotFoundInLocalStorageError = BrivoError(statusCode: -1004, errorDescription: "Acess point not found in local storage")
@objc public static let passNotFoundInLocalStorageError = BrivoError(statusCode: -1005, errorDescription: "Pass not found in local storage")
@objc public static let missingBLECredentialError = BrivoError(statusCode: -1006, errorDescription: "Missing ble credential")
@objc public static let accessPointInvalidDoorType = BrivoError(statusCode: -1007, errorDescription: "Access point invalid door type")
@objc public static let missingNetworkConnectionError = BrivoError(statusCode: -1008, errorDescription: "Missing internet connection")
@objc public static let missingReaderUUIDError = BrivoError(statusCode: -1009, errorDescription: "Missing reader UUID")
@objc public static func brivoErrorWithDescription(_ description: String) -> BrivoError {
return BrivoError(statusCode: -1010, errorDescription: description)
}
}
public struct BrivoBLEErrors {
public static let unknownError = BrivoError(statusCode: -2000, errorDescription: "Failed to unlock bluetooth door")
public static let poweredOffError = BrivoError(statusCode: -2001, errorDescription: "BLE disabled on device")
public static let failedTransmissionError = BrivoError(statusCode: -2004, errorDescription: "Failed BLE transmission")
public static let unauthorizedError = BrivoError(statusCode: -2005, errorDescription: "Access Denied")
public static let authenticationTimedOut = BrivoError(statusCode: -2006, errorDescription: "BLE Authentication timed out")
public static let unsupportedError = BrivoError(statusCode: -2007, errorDescription: "Bluetooth unsupported")
public static let peripheralError = BrivoError(statusCode: -2008, errorDescription: "BLE peripheral error")
public static let confirmError = BrivoError(statusCode: -2009, errorDescription: "Failed to call API")
public static func brivoBleErrorWithDescription(_ description: String) -> BrivoError {
return BrivoError(statusCode: -2010, errorDescription: description)
}
}
public enum BrivoNFCErrorType: Int, CaseIterable {
case walletProvisioning = -5000
case nfcCredentialStatus = -5001
case addToWallet = -5002
case unlink = -5003
case unknown = -5004
}
public class BrivoNFCError: NSObject {
public static func walletProvisioning(error: WalletConfigurationError) -> BrivoError {
BrivoError(statusCode: BrivoNFCErrorType.walletProvisioning.rawValue,
errorDescription: "Wallet provisioning: \(error.localizedDescription)",
context: error)
}
public static func nfcCredentialStatus(reason: String) -> BrivoError {
BrivoError(statusCode:BrivoNFCErrorType.nfcCredentialStatus.rawValue, errorDescription: "NFC credentials: \(reason)")
}
public static func addToWallet(reason: String) -> BrivoError {
BrivoError(statusCode: BrivoNFCErrorType.addToWallet.rawValue, errorDescription: "Add to wallet: \(reason)")
}
public static func unlink(reason: String) -> BrivoError {
BrivoError(statusCode: BrivoNFCErrorType.unlink.rawValue, errorDescription: "Unlink: \(reason)")
}
public static func nfcErrorType(_ error: BrivoError) -> BrivoNFCErrorType {
BrivoNFCErrorType.allCases.first { $0.rawValue == error.statusCode } ?? BrivoNFCErrorType.unknown
}
}
如果您遇到任何错误或问题,请随时发布 问题 以进一步讨论。