2016-09-20 21 views
2

FacebookのログインをiOS 10アプリにswift 3.0と統合しようとしています。 FacebookSDKがアプリに設定した後、以下のように私は、エラーコード2500を取得:コンソール上エラーコード2500 Swift 3.0のFacebookログイン

エラーコード:loginViewController上

body =  { 
    error =   { 
     code = 2500; 
     "fbtrace_id" = FpAkfsaBAFc; 
     message = "An active access token must be used to query information about the current user."; 
     type = OAuthException; 
    }; 
}; 
code = 400; 
}}) 

loginButton機能:

func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!) { 

    fetchProfile() 
    print("@@@@Completed [email protected]@@@") 

} 

をloginVCのフェイスブックプロファイル機能:

func fetchProfile() { 


    let parameters = ["fields": "email, first_name, last_name, picture.type(large)"] 

    FBSDKGraphRequest(graphPath: "me", parameters: parameters).start(completionHandler: { (connection, user, requestError) -> Void in 

     if requestError != nil { 
      print(requestError) 
      print("There are some error during getting the request from fb") 
      return 
     } 

     self.email = (user?["email"] as? String)! 
     self.firstName = (user?["first_name"] as? String)! 
     self.lastName = (user?["last_name"] as? String)! 

     self.nameLabel.text = "\(self.firstName) \(self.lastName)" 
     print("My fbname is " + self.firstName) 
     print(self.lastName) 

     var pictureUrl = "" 

     if let picture = user?["picture"] as? NSDictionary, let data = picture["data"] as? NSDictionary, let url = data["url"] as? String { 
      pictureUrl = url 
      print(pictureUrl) 
     } 

    }) 
} 

AppDelegate.swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 
    // Override point for customization after application launch. 

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions) 

    return true 
} 



func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: AnyObject) -> Bool { 
    return FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation) 
} 

は、スタックオーバーフロー上で同様の質問を検索していたが、SWIFT 3.0上で動作していない、誰もがこの問題について助言することができれば理解されるだろう、感謝と素敵なを持っています日!

答えて

1

は私がキーチェーンの下で機能の共有を有効にし、問題を解決していたし、Facebookのログインが完璧に働いています!

1

エラーメッセージに示すように、access_tokenがありません。リクエストを作成してaccess_tokenがnilであるかどうかを確認してから、新しいリクエストを要求する前にコントロールを作成します。その後、あなたはあなたの要求をすることができるはずです。キーチェーンアクセスがiOS10にデフォルトで無効にされているように

+1

ありがとうございました! – aznelite89

関連する問題