Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在不使用CLI的情况下使用swift为社交登录本机设置AWS Cognito?_Ios_Swift_Facebook_Amazon Cognito_Google Signin - Fatal编程技术网

Ios 如何在不使用CLI的情况下使用swift为社交登录本机设置AWS Cognito?

Ios 如何在不使用CLI的情况下使用swift为社交登录本机设置AWS Cognito?,ios,swift,facebook,amazon-cognito,google-signin,Ios,Swift,Facebook,Amazon Cognito,Google Signin,在我们的应用程序中,我们使用AWSCognitoIdentityProvider进行Cognito身份验证。我们能够成功注册、登录、重置密码等,但我很难找到一个完整的示例来帮助我通过社交提供商(如facebook、google)设置身份验证。在我的Cognito中,我已经成功地将google与我的用户池连接起来,并使用一个web URL,我能够成功地为他们创建一个Cognito“sub”,但希望我能在Swift中获得一些关于设置它的帮助 在我的Cognito中,我已经成功地将google与我的用

在我们的应用程序中,我们使用AWSCognitoIdentityProvider进行Cognito身份验证。我们能够成功注册、登录、重置密码等,但我很难找到一个完整的示例来帮助我通过社交提供商(如facebook、google)设置身份验证。在我的Cognito中,我已经成功地将google与我的用户池连接起来,并使用一个web URL,我能够成功地为他们创建一个Cognito“sub”,但希望我能在Swift中获得一些关于设置它的帮助

在我的Cognito中,我已经成功地将google与我的用户池连接起来,并使用一个web URL,我能够成功地为他们创建一个Cognito“sub”,但希望我能在Swift中获得一些关于设置它的帮助

这是我的AppDelegate.swift:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

            // setup logging
            AWSDDLog.sharedInstance.logLevel = .verbose
            AWSDDLog.add(AWSDDTTYLogger.sharedInstance)

            // setup cognito config
            self.cognitoConfig = CognitoConfig()

            // setup cognito
            setupCognitoUserPool()

            return true
    }

    func setupCognitoUserPool() {
        let clientId:String = self.cognitoConfig!.getClientId()
        let poolId:String = self.cognitoConfig!.getPoolId()
        let clientSecret:String = self.cognitoConfig!.getClientSecret()
        let region:AWSRegionType = self.cognitoConfig!.getRegion()

        let serviceConfiguration:AWSServiceConfiguration = AWSServiceConfiguration(region: region, credentialsProvider: nil)
        let cognitoConfiguration:AWSCognitoIdentityUserPoolConfiguration = AWSCognitoIdentityUserPoolConfiguration(clientId: clientId, clientSecret: clientSecret, poolId: poolId)
        AWSCognitoIdentityUserPool.register(with: serviceConfiguration, userPoolConfiguration: cognitoConfiguration, forKey: userPoolID)
        let pool:AWSCognitoIdentityUserPool = AppDelegate.defaultUserPool()
        pool.delegate = self 
    }
以下是迄今为止我拥有的基于电子邮件的身份验证代码,我正在为FB/Google寻找类似的代码:

@IBAction func loginPressed(_ sender: AnyObject) {
            let username:String = usernameInput?.text ?? "No username found"
            let password:String = passwordInput?.text ?? "No password found"

            // some code to check if username/password fields are empty. Throw error.

            user = AppDelegate.defaultUserPool().currentUser()

            self.user?.getSession(username, password: password, validationData: nil).continueWith {(task) -> AnyObject? in
                DispatchQueue.main.async (execute: {
                    let userSessionStatus = self.user?.isSignedIn

                    if userSessionStatus == true {
                            // take the user to welcome screen view controller
                    } else {
                            // Login failed. Ask the user to retry
                    }

                })
                return nil
            }
        }

有什么帮助吗?如果其他人能够解决这个问题,我会很乐意解决这个问题。我的研究发现了这些问题,但没有明确的答案: