firebaseを使用したiOSアプリでtwitter認証を使っているのですが、なぜかtwitter app 有り画面の後に 無し画面が立て続けに表示されてしまいます。
plist
1// info.plist 2 <array> 3 <dict> 4 <key>CFBundleURLSchemes</key> 5 <array> 6 <string>twitterkit-APIキー</string> 7 </array> 8 </dict> 9 </array>
swift
1 2// AppDelegate.swift 3 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 4 if ApplicationDelegate.shared.application(application, didFinishLaunchingWithOptions: launchOptions) { 5 return true 6 } 7 GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID 8 TWTRTwitter.sharedInstance().start(withConsumerKey: "APIキー", consumerSecret: "シークレットキー") 9 return true 10 } 11 12 13 @available(iOS 9.0, *) 14 func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) 15 -> Bool { 16 17 if TWTRTwitter.sharedInstance().application(application, open: url, options: options) { 18 return true 19 } 20 21 22 return true 23 24 }
swift
1// LoginViewController 2 // MARK: Twitter認証 3 4 @IBAction func tapTwitterLogin(_ sender: Any) { 5 TWTRTwitter.sharedInstance().logIn(completion: { (session, error) in 6 print(session) 7 guard session != nil else { 8 print("error: (error!.localizedDescription)") 9 return 10 } 11 let authToken = session!.authToken 12 let authTokenSecret = session!.authTokenSecret 13 14 let credential = TwitterAuthProvider.credential(withToken: authToken, secret: authTokenSecret) 15 print("signed in as (session!.userName)") 16 17 Auth.auth().signIn(with: credential) { (authResult, error) in 18 if let error = error { 19 print("error: (error.localizedDescription)") 20 return 21 22 } 23 //Sign In Completed 24 print("ログイン成功") 25 26 27 } 28 29 30 }) 31 32 } 33コード
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。