iOS Tutorials: Login & Sign Up using Firebase

OVERVIEW

One of the most important features implemented on apps are the ability to login and sign up. The reason behind this important features is the ability to store information of the user according to his/her preferences. In this tutorial, we will be using Firebase which is owned by Google and we trust Google for it’s reliability and speed in handling huge database.

Firebase is currently used by many different companies that include Shazzam, Skyscanner and many others. We can see why these big companies trusted Firebase.

Designing the UI

Create your first project and go to Main.storyboard and design the UI.

Informations on the left are objects from the object library which could be accessed from the bottom right corner and informations on the right are the attributes in the file inspector. There are three classes with the following name subclass of ViewController.

Configuring the Firebase settings

Go to Firebase Google to register an account and when you are done, click Go to Console > Add Project and insert the information needed.

Click on Add Firebase to your iOS app

Make sure that you iOS Bundle ID is the same on your project.

Click Download GoogleService-Info.plist and drag and drop the file on your project as indicated on the instruction.

This step is a little bit more complicated but I’ll guide you through in my other tutorial if you have never done this before. CocoaPods is a dependency manager meaning, framework that had been built by different developer to make your life easier in which you could import their library and write a shorter code.

 

Your Podfile should import an additional SDK, Firebase/Auth here.

In addition to importing Firebase here, add one additional line of code. If you did not add this line of code, you’ll encounter an error.

 

At this point, your project should look exactly like the above. Next, we’ll have to go to Firebase Console to configure some of the settings to enable the email and password settings.

Let’s move to the coding section for FrontPageViewController.swift first. The code section of this mainly helps user to login. And if clicked on Create new account, it will lead to a different page where you could create an account.

Now, let’s edit some code at SignUpViewController.swift where users could register their account by entering an email address and password.

Then, we would also like to see HomeViewController.swift where user logged in with their newly created account. Here, we would like to display the email addresses used to login.

If everything is done correctly, your app should look like this:

 

Project can be downloaded from GitHub

  • Article By :
    Founder of DaddyCoding. Studied Computer Science, Information System and Information Technology at BYU-Hawaii. Currently spending most of my time researching and learning on helping to expose making iOS apps.

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*