iOSアプリ(swift)で、Googleアカウント連携したいです。
クラウドは独自のもので”testCloud.net”で構築しています。
こちらにアカウント情報を保持したいので、Web同様にこちらのクラウドを経由してOauth認証したいのですが可能なのでしょうか?
現状はサイトなどを参考に以下のような感じで色々試しています。
swift
1import UIKit 2import SafariServices 3 4class mainViewController: UIViewController,SFSafariViewControllerDelegate { 5 6 override func viewDidLoad() { 7 super.viewDidLoad() 8 NotificationCenter.default.addObserver(self, selector: #selector(safariLogin(_:)), name: Notification.Name("CallbackNotification"), object: nil) 9 } 10 11 @IBAction func loginButtonTask(_ sender: Any) { 12 let authURL:URL = URL(string: "https://testCloud.net/login/google")! 13 let safariVC = SFSafariViewController(url: authURL) 14 safariVC.delegate = self 15 self.present(safariVC, animated: true, completion: nil) 16 } 17 18 @objc func safariLogin(_ notification: NSNotification) { 19 let url = notification.object as! NSURL 20 NotificationCenter.default.removeObserver(self, name: Notification.Name("CallbackNotification"), object: nil) 21 print("Debug1:::(url)") 22 } 23 24 func safariViewControllerDidFinish(_ controller: SFSafariViewController) { 25 NotificationCenter.default.removeObserver(self, name: Notification.Name("CallbackNotification"), object: nil) 26 } 27 28 override func didReceiveMemoryWarning() { 29 super.didReceiveMemoryWarning() 30 } 31} 32
特定のURL(testCloud.net/callbackのようなCallbackされた場合)で、SFSafariViewControllerを自動で抜けたいのですが、可能なのでしょうか?
ご教授を願います。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。