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

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

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

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

0回答

1549閲覧

Cognitoを使用してiOSアプリでログイン機能を実装したい

JunZenpou

総合スコア24

iOS

iOSとは、Apple製のスマートフォンであるiPhoneやタブレット端末のiPadに搭載しているオペレーションシステム(OS)です。その他にもiPod touch・Apple TVにも搭載されています。

Swift

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

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

1クリップ

投稿2017/08/02 08:26

編集2017/08/03 08:37

###前提・実現したいこと
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を使用しています。

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

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

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

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

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

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問