kAiN kAiN - 3 years ago 316
Objective-C Question

Facebook / Google Login with Fireboard show always alert

I'm trying to use Facebook and Google login through Firebase for user management.

P.S. I Follow the Firebase Documentation

Everything works well for now but I have a problem ...

1. I do not understand why every time I push the facebbok login button or the google login button I see this Alert ...

enter image description here
enter image description here

Is it possible to show the alert only once? what should it always show?

2. We come to the second problem. Each time my app reaches the page where the user chooses to login, the same alert appears that I showed you at the top of the photo ... In this case, the user has not yet selected any login method Google's alert should not immediately appear.

Can you help me with this?

This is my code from App Delegate where is Google button and Facebook set

#import "AppDelegate.h"
@import Firebase;
@import GoogleSignIn;
@import FBSDKCoreKit;

@interface AppDelegate () <GIDSignInDelegate>


@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[FIRApp configure];

[GIDSignIn sharedInstance].clientID = [FIRApp defaultApp].options.clientID;
[GIDSignIn sharedInstance].delegate = self;

[[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

return YES;

- (BOOL)application:(nonnull UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *, id> *)options {

BOOL handled = [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];

[[GIDSignIn sharedInstance] handleURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];

return handled;

// GOOGLE GIDSignInDelegate
- (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error {

if (error == nil) {
GIDAuthentication *authentication = user.authentication;
FIRAuthCredential *credential = [FIRGoogleAuthProvider credentialWithIDToken:authentication.idToken accessToken:authentication.accessToken];

[[FIRAuth auth] signInWithCredential:credential completion:^(FIRUser * _Nullable user, NSError * _Nullable error) {
if (error) {
NSLog(@"Nessun account registrato su FireBase da Google errore: %@", error);

NSLog(@"%@", credential);
return ;
NSLog(@"Registrazione Completata");

} else NSLog(@"LOGIN GOOGLE ERRORE %@", error);


This is my viewController with facebook button

#import "KPValidation.h"
@import Firebase;
@import GoogleSignIn;
@import FBSDKLoginKit;
@import FBSDKCoreKit;

@interface KPValidation () <GIDSignInUIDelegate, FBSDKLoginButtonDelegate>


@implementation KPValidation

- (void)viewDidLoad {
[super viewDidLoad];

[self setupGoogleButton];
[self setupFacebookButton];

-(void)setupFacebookButton {
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.delegate = self;
loginButton.translatesAutoresizingMaskIntoConstraints = NO;
loginButton.readPermissions = @[@"email", @"public_profile"];
[self.view addSubview:loginButton];

[loginButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor constant:-100].active = YES;
[loginButton.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
[loginButton.rightAnchor constraintEqualToAnchor:self.view.rightAnchor].active = YES;
[loginButton.heightAnchor constraintEqualToConstant:50].active = YES;

- (void)loginButton:(FBSDKLoginButton *)loginButton didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result error:(NSError *)error {

FIRAuthCredential *credential = [FIRFacebookAuthProvider credentialWithAccessToken:[FBSDKAccessToken currentAccessToken].tokenString];

[[FIRAuth auth] signInWithCredential:credential completion:^(FIRUser *user, NSError *error) {
if (error) {
// ...

// User successfully signed in. Get user data from the FIRUser object
// ...

NSLog(@"%@", user.email);
// [self showEmail];


Answer Source
  • Question 1: You should take a look at this Additional alert shows up using AppAuth to authenticate in swift4

  • Question 2: I think in your application:openURL:options: method, you should check input url. If it's Facebook url, use FBSDKApplicationDelegate else use GIDSignIn.

    - (BOOL)application:(nonnull UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *, id> *)options {
      if (/*url is Facebook url*/) {
        return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
      } else {
        return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:options[UIApplicationOpenURLOptionsSourceApplicationKey] annotation:options[UIApplicationOpenURLOptionsAnnotationKey]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download