Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleAuth using Firebase in IOS

I am following the instructions of the official Firebase channel (https://firebase.google.com/docs/auth/ios/google-signin?hl=en-419) to subscribe into my app using Google authentication. The problem appears in the function

func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?)  

Where it does not resolve the identifiers GoogleAuthProvider and Auth from the commands. i.e. "Use of unresolved identifier 'GoogleAuthProvider'"

let credential = GoogleAuthProvider.credential(idToken: authentication.idToken, accessToken: authentication.accessToken)
        // ...
Auth.auth().signIn(with: credential) { (user, error) in
            if let error = error {
                // ...
                return
            } 

I imported in both the viewer and the AppDelegate:

import Firebase
import GoogleSignIn

And my Podfile looks like that:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'racc' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!

  # Pods for racc
  pod 'Firebase/Core'
  pod 'GoogleSignIn'
  pod 'Firebase/Auth'

  target 'raccTests' do
    inherit! :search_paths
    # Pods for testing
  end

end

I am working in Swift 4

like image 475
Hector Esteban Avatar asked May 02 '18 16:05

Hector Esteban


People also ask

What is Firebase used for in IOS?

Google Firebase is a Google-backed application development software that enables developers to develop iOS, Android and Web apps. Firebase provides tools for tracking analytics, reporting and fixing app crashes, creating marketing and product experiment.

How do I authenticate with Firebase?

You can sign in users to your Firebase app either by using FirebaseUI as a complete drop-in auth solution or by using the Firebase Authentication SDK to manually integrate one or several sign-in methods into your app. The recommended way to add a complete sign-in system to your app.

Is Firebase good for authentication?

FirebaseUI provides a customizable, open source, drop-in auth solution that handles the UI flows for signing in users. The FirebaseUI Auth component implements best practices for authentication on mobile devices and websites, which can maximize sign-in and sign-up conversion for your app.

Is Firebase Auth free?

Prices are per successful verification. On the Blaze plan, Phone Authentication provides a no-cost tier. The first 10K verifications for both instances (USA, Canada, and India and All other countries) are provided at no cost each month. You are only charged on usage past this no-cost allotment.


2 Answers

You need to import FirebaseAuth into your App Delegate.

In your Podfile: pod 'Firebase/Auth'

In your AppDelegate: import FirebaseAuth

These steps are missing from the official Google instructions.

like image 68
Sam Coe Avatar answered Sep 20 '22 22:09

Sam Coe


It's most likely that you do not have Google Login enabled in your Firebase Dashboard. To enable, go to the Firebase Dashboard, and click on your project.

From there, tap Authentication, and Sign-In Method. Find Google, and hit Enable.

Screenshot of Sign-In Method

like image 36
Matthew Knippen Avatar answered Sep 16 '22 22:09

Matthew Knippen