Function: Login and Logout

In order for the user to see private contentApps, a login is required.

Example for a Login and Logout
import UIKit
import CDockFramework

class VCCustomLogin: UIViewController {
    
    @IBOutlet weak var tfLogin: UITextField!
    @IBOutlet weak var tfPass: UITextField!
    @IBOutlet weak var stackLogin: UIStackView!
    @IBOutlet weak var btnLogout: UIButton!
    
    @IBAction func onBtnLogoutTapped(_ sender: Any) {
        CDockSDK.logOut()
        self.refreshState()
    }
    
    @IBAction func onBtnLogInTapped(_ sender: Any) {
        CDockSDK.login(with: self.tfLogin.text, password: self.tfPass.text, domain: "Set here your contentDock Web Address") {[weak self] b in
            self?.refreshState()
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        self.refreshState()
    }

    func refreshState() {
        if CDockSDK.isLoggedIn() {
            stackLogin.isHidden = true
            btnLogout.isHidden = false
        }
        else {
            stackLogin.isHidden = false
            btnLogout.isHidden = true
        }
    }
}

Feedback or Questions

We are always happy to help you with questions about the code or other questions.

Was this page helpful? Yes No

Topics on this page