

dependencies: [
.package(url: "https://github.com/William-Weng/WWSignInWith3rd_GitHub.git", .upToNextMajor(from: "1.0.0"))
]
函数 |
功能 |
configure(clientId:secret:callbackURL:scope:) |
参数设定 |
loginWithWeb(presenting:completion:) |
登录 - 网页 |
logoutWithWeb(contains:completion:) |
登出 - 清除GitHub偷偷存在WebView里面的Cookie值 => 记录登录的值 |
import UIKit
import WWPrint
import WWSignInWith3rd_Apple
import WWSignInWith3rd_GitHub
final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initSetting()
}
/// [GitHub 第三方登入](https://developer.github.com)
@IBAction func signInWithGithub(_ sender: UIButton) {
WWSignInWith3rd.GitHub.shared.loginWithWeb(presenting: self) { result in
wwPrint(result)
}
}
}
// MARK: - 小工具
extension ViewController {
func initSetting() {
let clientId = "<clientId>"
let secret = "<secret>"
let callbackURL = "<callbackURL>"
WWSignInWith3rd.GitHub.shared.configure(clientId: clientId, secret: secret, callbackURL: callbackURL)
}
}