我正在使用 AWS iOS SDK v2 和 Facebook iOS SDK v2.2。我正在尝试使用 Facebook 令牌作为 AWS 凭证提供商的“登录名”。问题是,我不知道如何在 iOS Swift 中设置登录。下面是我的代码:
if (FBSession.activeSession().state == FBSessionState.CreatedTokenLoaded) {
// If there's one, just open the session silently, without showing the user the login UI
FBSession.openActiveSessionWithReadPermissions(["public_profile", "email", "user_friends"], allowLoginUI: false, completionHandler: { (fbSession, fbSessionState, error) -> Void in
// Handler for session state changes
// This method will be called EACH time the session state changes,
// also for intermediate states and NOT just when the session open
if (error == nil) && (fbSessionState == FBSessionState.Open) {
var token: String = fbSession.accessTokenData.accessToken
var logins: NSDictionary = NSDictionary(dictionary: ["AWSCognitoLoginProviderKey.Facebook" : token])
self.credentialsProvider.logins = logins
self.credentialsProvider.refresh()...}
但我不认为登录字典是正确的......我试过了
[AWSCognitoLoginProviderKey.Facebook:令牌]
但是 XCode 说它不符合 NSCopying。
这里非常欢迎提示!谢谢!!!