0

I was getting "This app is in development mode” error when trying to auth with FirebaseUI + Facebook. This was solved by making the app "available to the general public". After that I'm getting another error which reads

"The user does not have sufficient rights to view the application. User can not view this application due to developer settings"

and logs

2018-07-20 17:56:30.610332+0700 SamuiPlus[79114:33415252] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2018-07-20 17:56:30.610602+0700 SamuiPlus[79114:33415252] Falling back to storing access token in NSUserDefaults because of simulator bug 2018-07-20 17:56:30.612003+0700 SamuiPlus[79114:33415252] -canOpenURL: failed for URL: "fbauth2:/" - error: "The operation couldn’t be completed. (OSStatus error -10814.)" 2018-07-20 17:56:31.913536+0700 SamuiPlus[79114:33502682] TIC Read Status [12:0x0]: 1:57 2018-07-20 17:56:31.913974+0700 SamuiPlus[79114:33502682] TIC Read Status [12:0x0]: 1:57 2018-07-20 17:56:32.078459+0700 SamuiPlus[79114:33415252] INFO: Reveal Server started (Protocol Version 43). 2018-07-20 17:56:32.084358+0700 SamuiPlus[79114:33415252] Could not successfully update network info during initialization. 2018-07-20 17:56:32.136652+0700 SamuiPlus[79114:33415252] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction 2018-07-20 17:56:32.647304+0700 SamuiPlus[79114:33502692] TIC Read Status [13:0x0]: 1:57 2018-07-20 17:56:32.647397+0700 SamuiPlus[79114:33502692] TIC Read Status [13:0x0]: 1:57

I followed all official instructions on setting up firebase & facebook in my app (info.plist, url types), tried different settings on developers.facebook.com, still don't understand what might cause the issue. On android version of the app login with Facebook works fine.

presenting AuthViewController

func showAuthUI(delegate: FUIAuthDelegate) {
    presentModalViewControllerDerivedFrom({ (_) -> UIViewController in
        let authUI = FUIAuth.defaultAuthUI()
        authUI?.delegate = delegate
        let authViewController = authUI!.authViewController()
        return authViewController
    }, animation: true, completion: nil)
}

FUIAuthDelegate

  extension ProfilePresenter: FUIAuthDelegate {

    func authUI(_ authUI: FUIAuth, didSignInWith authDataResult: AuthDataResult?, error: Error?){
        if let error = error as NSError? {
            if let errorMessage = error.userInfo["NSLocalizedDescription"] as? String {
                //Show Alert with message provided in 'errorMessage'
                print("auth ui didSignInWith authDataResult, error: \(errorMessage)")
            } else {
                //Show General Alert
                print("auth ui didSignInWith authDataResult, general error")
            }
        } else if let user = authDataResult?.user {
            //Logged in
            // ...
        } else {
            // Unknow State
            print("auth ui didSignInWith authDataResult, unknown state")
        }
    }
}

AppDelegate

  override init() {
        super.init()
        FirebaseApp.configure()
        let authUI = FUIAuth.defaultAuthUI()
    }

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {

        let authUI = FUIAuth.defaultAuthUI()

        let providers: [FUIAuthProvider] = [
            FUIGoogleAuth(),
            FUIFacebookAuth(permissions: ["public_profile", "email"]),
            FUIPhoneAuth(authUI:FUIAuth.defaultAuthUI()!),
            ]
        authUI?.providers = providers

        return true
    }

  func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
        let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String?
        if FUIAuth.defaultAuthUI()?.handleOpen(url, sourceApplication: sourceApplication) ?? false {
            return true
        }
        // other URL handling goes here.
        return false
    }

Login with other providers works just fine. Thanks in advance for any help.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
AlexKost
  • 2,792
  • 4
  • 22
  • 42

1 Answers1

3

I hope you create facebook auth Id you just want to put this code and call this function from anywhere in your project.

In AppDelegate

In applicationDidFinishLaunchingWithOptions

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

In UIApplicationOpenURLOptionsKey function

return FBSDKApplicationDelegate.sharedInstance().application(app, open: url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as! String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])

Then create custom class For FacebookAuth.swift and create function for facebookLogin.

    func faceBookLogin() {
      let fbLoginManager : FBSDKLoginManager = FBSDKLoginManager()
      fbLoginManager.logIn(withReadPermissions: ["email"], from: 
      (self.senderController as! LoginViewController)) { (result, error) -> 
      Void in
      if (error == nil){
       let facebookLoginResult : FBSDKLoginManagerLoginResult = result!
       if (result?.isCancelled)!{
            return
        }
        if(facebookLoginResult.grantedPermissions.contains("email")){
            self.getFacebookUserData()
        }else{

        }
     }else{

        }
      }
  }

Then get facebook user data create function of getFaceBookUserData() that we get facebook user data.

func getFacebookUserData(){
        if((FBSDKAccessToken.current()) != nil){
            FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "id, first_name, last_name, email"]).start(completionHandler: { (connection, result, error) -> Void in
                if (error == nil){
                    if let userData = result as? NSDictionary{
                        print(userData)
                     }
                }else{

                }
            })
        }
    }
Abhishek Jadhav
  • 706
  • 5
  • 12
  • 1
    Thanks for your reply. You're suggesting me to use 'FBSDKLoginKit', right?. But as you can see in the question, I'm using FirebaseUI solution, which shows login button for different providers (everything works, except Facebook). So to try out your solution I need a way to handle FirebaseUI's 'Login with Facebook' button click somehow. Any ideas? – AlexKost Jul 21 '18 at 03:09