GatewayAPI

Undocumented

  • tag

    Undocumented

  • app

    Undocumented

  • Undocumented

  • Access token of this gate way

    Declaration

    Swift

    open internal(set) var accessToken: String?
  • Initialize GatewayAPI.

    If you want to store GatewayAPI instance to storage, you need to set tag.

    tag is used to distinguish storage area of instance. If the api instance is tagged with same string, It will be overwritten. If the api instance is tagged with different string, Different key is used to store the instance.

    Please refer to GatewayAPI.loadWithStoredInstance(_:)

    Declaration

    Swift

    public init(_ app: KiiApp, gatewayAddress: URL, tag: String? = nil)
  • Login to the Gateway. Local authentication for the Gateway access. Required prior to call other APIs access to the gateway.

    Declaration

    Swift

    open func login(
            _ username: String,
            password: String,
            completionHandler: @escaping (ThingIFError?)-> Void) -> Void
  • Let the Gateway Onboard.

    Declaration

    Swift

    open func onboardGateway(
            _ completionHandler: @escaping (Gateway?, ThingIFError?)-> Void
            )
  • Get Gateway ID

    Declaration

    Swift

    open func getGatewayID(
            _ completionHandler: @escaping (String?, ThingIFError?)-> Void
            )
  • List connected end nodes which has been onboarded.

    Declaration

    Swift

    open func listOnboardedEndNodes(
            _ completionHandler: @escaping ([EndNode]?, ThingIFError?)-> Void
            )
  • List connected end nodes which has not been onboarded.

    Declaration

    Swift

    open func listPendingEndNodes(
            _ completionHandler: @escaping ([PendingEndNode]?, ThingIFError?)-> Void
            )
  • Notify Onboarding completion Call this api when the End Node onboarding is done. After the call succeeded, End Node will be fully connected to Kii Cloud through the Gateway.

    Declaration

    Swift

    open func notifyOnboardingCompletion(
            _ endNode: EndNode,
            completionHandler: @escaping (ThingIFError?)-> Void
            )
  • Restore the Gateway. This API can be used only for the Gateway App.

    Declaration

    Swift

    open func restore(
            _ completionHandler: @escaping (ThingIFError?)-> Void
            )
  • Replace end-node by new vendorThingID for end node thingID.

    Declaration

    Swift

    open func replaceEndNode(
            _ endNodeThingID: String,
            endNodeVendorThingID: String,
            completionHandler: @escaping (ThingIFError?)-> Void
            )
  • Get information of the Gateway. When the end user replaces the Gateway, Gateway App/End Node App need to obtain the new Gateway’s vendorThingID.

    Declaration

    Swift

    open func getGatewayInformation(
            _ completionHandler: @escaping (GatewayInformation?, ThingIFError?)-> Void
            )
  • Check if user is logged in to the Gateway.

    Declaration

    Swift

    open func isLoggedIn() -> Bool

    Return Value

    true if user is logged in, false otherwise.

  • Try to load the instance of GatewayAPI using stored serialized instance.

    Instance is automatically saved when login method is called and successfully completed.

    If the GatewayAPI instance is build without the tag, all instance is saved in same place and overwritten when the instance is saved.

    If the GatewayAPI instance is build with the tag(optional), tag is used as key to distinguish the storage area to save the instance. This would be useful to saving multiple instance.

    When you catch exceptions, please call login for saving or updating serialized instance.

    Declaration

    Swift

    open static func loadWithStoredInstance(
          _ tag : String? = nil) throws -> GatewayAPI

    Return Value

    GatewayIFAPI instance.

  • Clear all saved instances in the NSiotUserDefaults.

    Declaration

    Swift

    open static func removeAllStoredInstances() -> Void
  • Remove saved specified instance in the NSiotUserDefaults.

    Declaration

    Swift

    open static func removeStoredInstances(
          _ tag : String? = nil) -> Void
  • Save this instance

    This method use NSiotUserDefaults. Should not use the key GatewayAPI_INSTANCE, this key is reserved.

    Declaration

    Swift

    open func saveInstance() -> Void