0

I have implement login with Facebook and its work great on staging and on production also for some user, it's working but for some it not and I am not getting any track or reference, why this is occurring with only some user, whereas I am not able to replicate the error.

Any help or suggestion will be helpful

Fabric crash report last lines

30 CoreFoundation                 0x190fc22b8 CFRunLoopRunSpecific + 444
31 GraphicsServices               0x192a76198 GSEventRunModal + 180
32 UIKit                          0x1970097fc -[UIApplication _run] + 684
33 UIKit                          0x197004534 UIApplicationMain + 208
34 AppName                          0x100066f50 main (AppDelegate.swift:64)
35 libdispatch.dylib              0x18ffa55b8 (Missing)

Facebook login code

 UIView.animate(withDuration: 0.05, animations: {
        self.loginWithFacebookView.alpha = 0
    }, completion: { (true) in
        UIView.animate(withDuration: 0.05, animations: {
            self.loginWithFacebookView.alpha = 1
            }, completion : { (true) in
                self.showLoadingHUD("Signing in with facebook")
                self.facebookLogin = FBSDKLoginManager()
                self.facebookLogin.logIn(withReadPermissions: [EMAIL, PUBLIC_PROFILE], from: self, handler: { (facebookResult, facebookError) in
                    if facebookError != nil {
                        self.showAnAlert("Oops!", message: "\(String(describing: facebookError))")
                        self.hideLoadingHUD()
                    } else if (facebookResult?.isCancelled)! {
                        self.showAnAlert("Oops!", message: "\("Error while signing up")")
                        self.hideLoadingHUD()
                    } else if (facebookResult?.declinedPermissions.contains("email"))! {
                        print("email not granted")
                        FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, httpMethod: "DELETE").start(completionHandler: {(_ connection: FBSDKGraphRequestConnection, _ result: Any, _ error: Error?) -> Void in
                        } as? FBSDKGraphRequestHandler)
                        self.hideLoadingHUD()
                        self.showAnAlert("Error", message: "Error while sign in - Email is required")
                    }
                      else {
                        let accessToken = FBSDKAccessToken.current().tokenString
                        let credential = FIRFacebookAuthProvider.credential(withAccessToken: accessToken!)
                        FIRAuth.auth()?.signIn(with: credential) { (user, error) in
                                if error != nil {
                                    self.showAnAlert("Oops!", message: "\(String(describing: facebookError))")
                                } else {

                                    _ = FBSDKGraphRequest(graphPath: "me", parameters: ["fields":"email,name"]).start { (connection, result, error) -> Void in
                                        if error == nil {
// grabing the data and registring it with firebase
}
Abdul Karim
  • 4,359
  • 1
  • 40
  • 55
  • Try to run authentication code into main thread. – Jageen Oct 03 '17 at 06:38
  • I just want you to make sure that this is not because of missing file inside facebook SDK, it is more like threading issue. – Jageen Oct 03 '17 at 06:39
  • @Jageen, here is the full crash report https://gist.github.com/abdulKarim002/307e114c8d61be60e1f1bc90cc87d0d0 can you go through it and give some insight – Abdul Karim Oct 03 '17 at 07:08
  • I could not do that righ now, but I can suggest one thing, instead of writing code in completion, Remove animation code and write only facebook auth, code. (If it will solve your issue it is threading issue) – Jageen Oct 03 '17 at 07:12
  • OR you can write your code in main thread see this -> https://stackoverflow.com/questions/38762919/run-closure-on-main-thread – Jageen Oct 03 '17 at 07:17
  • @Jageen I get your point to execute the code in main thread but still it's like guess right. – Abdul Karim Oct 03 '17 at 07:20
  • Yes it is guess but based on my experience, and that's the reason I did not write this as an answer :d. – Jageen Oct 03 '17 at 07:24
  • see this -> https://stackoverflow.com/questions/34849636/reporting-crash-on-uitableview-reloaddata – Jageen Oct 03 '17 at 07:25
  • @Jageen thankyou for suggestion, I had implemented it hope it won't crash – Abdul Karim Oct 03 '17 at 07:28
  • ur welcome, so did it work ? – Jageen Oct 04 '17 at 01:01
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/155865/discussion-between-abdul-karim-and-jageen). – Abdul Karim Oct 04 '17 at 05:08
  • @Jageen the suggestion worked , thankx it resolved the error – Abdul Karim Jan 03 '18 at 06:15

0 Answers0