###前提・実現したいこと
AWSのCognitoを使用して、iOSアプリでログイン機能を実装したいのですが、以下のようにコードを作成しました。
// // MainViewController.swift // LoginApp // import UIKit import AWSCore import AWSCognito import AWSS3 import AWSSNS import FBSDKCoreKit import FBSDKLoginKit class MainViewController: UIViewController { let REGION_TYPE = AWSRegionType.APNortheast1 let IDENTITY_POOL_ID = "" var myName: String? = nil override func viewDidLoad() { super.viewDidLoad() let token = FBSDKAccessToken.current() // Facebookのアクセストークンを取得する if(nil != token){ //Facebookのユーザー情報を取得する処理 FBSDKGraphRequest( graphPath: "me", parameters: ["fields": "name"] ).start(completionHandler: { (connection, result, error) -> Void in if (nil == error) { guard let data = result as? [String:Any] else { return } self.myName = data["name"] as? String print("myName:", self.myName!) // CognitoによるFacebook認証処理。 let credentialsProvider = AWSCognitoCredentialsProvider(regionType: self.REGION_TYPE, identityPoolId: self.IDENTITY_POOL_ID) let configuration = AWSServiceConfiguration(region: self.REGION_TYPE, credentialsProvider: credentialsProvider) AWSServiceManager.default().defaultServiceConfiguration = configuration credentialsProvider.logins = [AWSCognitoLoginProviderKey.Facebook.rawValue: token.tokenString] //認証できているかの確認 credentialsProvider.getIdentityId().continueWith { (task: AWSTask!) -> AnyObject! in if (nil == task.error) { print("Cognito identity id:", task.result!) } else { print("Error:", task.error?.localizedDescription as Any) //前の画面に戻る self.dismiss(animated: true, completion: nil) } } } else{ print("Error:" ,error?.localizedDescription as Any) //前の画面に出る self.dismiss(animated: true, completion: nil) } }) } else{ // トークンが取得できなかった場合は、前の画面に戻る self.dismiss(animated: true, completion: nil) } } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } @IBAction func touchSharingButton(_ sender: UIButton) { } @IBAction func touchCloseButton(_ sender: UIButton) { // 「閉じる」ボタンが押されたときの処理 FBSDKLoginManager().logOut() self.dismiss(animated: true, completion: nil) } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destinationViewController. // Pass the selected object to the new view controller. } */ }
###発生している問題・エラーメッセージ
credentialsProvider.logins = [AWSCognitoLoginProviderKey.Facebook.rawValue: token.tokenString]
上記のコードの部分で
Use of unresolved identifiered 'AWSCognitoLoginProviderKey'
のエラーが出ています。Podfileでライブラリはきちんとインストールしてimportしたのですが、なぜでしょうか。一年前に販売された本を見ながらコードを書いてるので、コード自体が古いかと思いますが、よろしくお願いいたします。
swift3、xcode8を使用しています。
あなたの回答
tips
プレビュー