質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

Q&A

解決済

1回答

350閲覧

iOSアプリ(swift)で、Googleアカウント連携

yamayamak

総合スコア131

Swift

Swiftは、アップルのiOSおよびOS Xのためのプログラミング言語で、Objective-CやObjective-C++と共存することが意図されています

0グッド

0クリップ

投稿2017/12/24 12:07

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を自動で抜けたいのですが、可能なのでしょうか?
ご教授を願います。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

https://developers.google.com/identity/sign-in/ios/start-integrating
の通りやるのが良さそうなので、こちらの通り実施します。

投稿2017/12/25 11:10

yamayamak

総合スコア131

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問