

dependencies: [
.package(url: "https://github.com/William-Weng/WWSignInWith3rd_LINE.git", .upToNextMajor(from: "1.1.0"))
]
函式 |
功能 |
configure(channelId:channelSecret:universalLinkURL:) |
参数设定 |
login(presenting:permissions:completion:) |
登入 |
loginButton(with:viewController:completion:) |
LINE 图标按键 |
canOpenURL(_:open:options:) |
在外部由URL Scheme开启 -> application(_:open:options:) |
canOpenUniversalLink(_:continue:restorationHandler:) |
在外部由UniversalLink开启 -> application(_:continue:restorationHandler:) |
import UIKit
import WWSignInWith3rd_Apple
import WWSignInWith3rd_LINE
@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
}
// MARK: - 相關設定
extension AppDelegate {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
_ = WWSignInWith3rd.LINE.shared.canOpenURL(app, open: url, options: options)
return true
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
_ = WWSignInWith3rd.LINE.shared.canOpenUniversalLink(application, continue: userActivity, restorationHandler: restorationHandler)
return true
}
}
import UIKit
import WWPrint
import WWSignInWith3rd_Apple
import WWSignInWith3rd_LINE
final class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
initSetting()
}
/// [Line 第三方登入](https://developers.line.biz)
@IBAction func signInWithLine(_ sender: UIButton) {
WWSignInWith3rd.LINE.shared.login(presenting: self) { result in
wwPrint(result)
}
}
}
// MARK: - 小工具
extension ViewController {
func initSetting() {
let channelId = "<channelId>"
let channelSecret = "<channelSecret>"
let universalLinkURL = "<universalLinkURL>"
WWSignInWith3rd.LINE.shared.configure(channelId: channelId, channelSecret: channelSecret, universalLinkURL: universalLinkURL)
}
}