NexkeyCore 1.1.6

NexkeyCore 1.1.6

Lukasz Dworakowski 维护。



NexkeyCore

用法

import NexkeyCore

let client = NexkeyCore.shared

// 1a. Initialization with an `apiKey` and `apiSecretKey` 
client.initialize(with: apiKey, apiSecretKey: apiSecret)

// 1b. Or with a session token based approach
client.initialize(with: Constants.nexkeyAPIKey)

client.signIn(
  with: identifier,
  password: password,
  error: { [weak self] (error) in
    debugPrint("ERROR: \(error.localizedDescription)")
    self?.handleError(error, popsBack: false)
  },
  completion: { [weak self] json in
    let result = json.dictionaryValue["result"] as? [String: Any]
    if let sessionToken = result?["sessionToken"] as? String {
      self?.sessionTokenBlock?(sessionToken)
    }
  }
)
client.initialize(with: apiKey, sessionToken: sessionToken)

// 2. Getting all user keys:
client.getAllUserKeys(
  error: { [weak self] error in
    debugPrint("ERROR: \(error.localizedDescription)")
    self?.handleError(error)
  },
  completion: { [weak self] json in
    let result = json.dictionaryValue["result"] as? [[String: Any]]
    self?.locks = result
    self?.pullToRefresh.endRefreshing()
  }
)

// 3. If you want to get an information about the status
client.delegate = self

// 4. For unlocking the lock remotely 
client.remoteUnlock(
  lockId: lockId,
  update: Update<HubStatus>(owner: self) { status in
    debugPrint(status)
  },
  error: { [weak self] error in
    debugPrint("ERROR: \(error.localizedDescription)")
    self?.dismiss(animated: true, completion: nil)
    self?.handleError(error)
  },
  completion: { (json) in
    debugPrint("INFO: \(json)")
  }
)

要求

  • iOS 9.0+
  • Xcode 8.0+

安装

CocoaPods

CocoaPods 是 Cocoa 项目的依赖管理器。

要安装 NexkeyCore,只需将以下行添加到您的 Podfile 中

pod 'NexkeyCore'

作者

常见问题解答 (FAQ)

变更日志

查看变更日志