iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 25
0
Mobile Development

小菜逼學習IOS系列 第 25

鐵人25天

在這篇開始要使用 NCCommunication 跟 Webkit,還沒裝 NCCommunication 套件的同仁們請點擊這

首先

import NCCommunication
import WebKit

與 NextCloud 連線

func connectUrl( serverUrl : String ) {
        NCCommunication.shared.getServerStatus(serverUrl: serverUrl) { (_ serverProductName: String?, _ serverVersion: String? , _ versionMajor: Int, _ versionMinor: Int, _ versionMicro: Int, _ extendedSupport: Bool, _ errorCode: Int, _ errorDescription: String) in
            if errorCode == 0 {
                print("success")
            }else{
                print("error")
            }
        }
    }

getURL username password

func APIAction( serverUrl : String , username : String , password : String)  {
        //MARK: - getURL username password
        NCCommunication.shared.getAppPassword(serverUrl: serverUrl, username: username, password: password) { (_  token : String?, _ errorCode : Int, _ errorDescription : String) in
        }
    }

在裡面打如果成功 errorcode = 0 ,就進行 login flow V2,若失敗就跳出提示框

if (errorCode == 0){
                //MARK: - LoginFlowV2
                NCCommunication.shared.getLoginFlowV2(serverUrl: serverUrl) { (_ token : String?,_  endpoint : String?,_  login: String?,_  errorCode : Int, _ errorDescription: String) in
                    self.loadURL(urlString: login!)
                    self.tokentest = token
                    self.endpointtest = endpoint
                    self.loginFlowV2Available = true
                    
                }
            }else{
                self.alertAction(title: "訊息", message: "輸入有誤")
                DispatchQueue.main.asyncAfter(deadline: .now() + 2){
                    self.dismiss(animated: true, completion: nil)
                }
                 
            }

上一篇
NextCloud Login Flow V2(上)、-倒數8天
下一篇
ios Kanna 解析 鐵人26
系列文
小菜逼學習IOS30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言