Integrating Firebase Authentication Into An iOS Project

Firebase

Hello to all. Today I will introduce you an iOS project with Firebase Authentication. What is the Firebase and Firebase Authentication? Let’s take a look with together.

What is Firebase?

Firebase is a toolkit and infrastructure that aims at supporting the process of building better applications and growing a successful business. More technically, it is a BAAS (short for Backend-as-a-service) which helps you to build better apps, websites, or games regardless of server-side coding, API or backend data storage.

What is Firebase Authentication?

Firebase Authentication provides backend services, easy-to-use SDKs, and ready-made UI libraries to authenticate users to your app. It supports authentication using passwords, phone numbers, popular federated identity providers like Google, Facebook and Twitter, and more.

How to install Firebase to an iOS Project?

Let’s create a new project or open your existing project.

Bundle Identifiers: cemkazim.TestFirebaseAuthentication (We will need it in the future.)

We have to install the pod in the project directory. (You can run these commands in terminal.)

cd /Users/yourname/Desktop/TestFirebaseAuthenticationpod initpod install

We have a podfile. Let’s open this file, add necessary codes and run ‘pod install’ code from terminal.

pod ‘Firebase/Auth’ // add in podfilepod install // run in terminal

OK. Follow the steps.

Step 1: Create a new Firebase Project.

Step 2: Enter a project name.

Step 3: Select ‘Authentication’ from the left frame.

Step 4: Determine a sign in method.

Step 5: For example, let’s choose this method as “email / password”.

Step 6: Register your app with Firebase

  • Click on the iOS icon.
  • Write your ‘Bundle Identifier’ in the ‘iOS bundle ID’. (Remember the first picture in this article.)
  • Click Download GoogleService-Info.plist to obtain your Firebase iOS config file (GoogleService-Info.plist). Move your config file into the root of your Xcode project. If prompted, select to add the config file to all targets.

It seems perfect. Now, define your objects to the class. (and import Firebase)

Let’s customize register and login button.

Register:

Build your project and open the Simulator. You will see the screen below. Now, enter your login information. And click on the registerButton. (After registration, our informations are saved in firebase.)

Wow, look at this!

  • First picture (from XCode debug console):
  • Second picture (from Firebase Console):

Registration completed successfully. OK. Now customize the loginButton.

Login:

Click on the loginButton.

  • First picture (from Simulator)
  • Second picture (from XCode debug console)

Thank you for reading.

💻 iOS Developer 🎸 Rock Musician

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store