Creating a Simple Log in and Sign up Screen with Google FireBase

Keeping track of users is almost as important as finding them. Firebase makes it easy to keep track of user information so that you as the developer can focus on user experience. Let’s make a simple Log in and Sign up page:

Method for authenticating Log-in:

The sign is button will check and initiate code if both fields do not contain empty string. If the fields contain strings it will then check FireBase to see if this userName Password combination exists. If it does not, we call a display alert to pop on the screen and segue to a new view controller.

Method For Creating an Account:

Similar to the Log in function, the sign up function checks to see that the fields contain strings and will pop a display alert if any of the fields are left empty.

Saving data: Once you have verified that the fields have been filled out correctly you can save that information to FireBase.

A few things on dismissing the keyboard:

We want the keyboard to dismiss every time we tap a part of the screen that is not the text box. The first code sets up this tap gesture to that will simulate what occurs when the user is done editing. Tapping anywhere on the view controller will call the Dismiss keyboard function. If we didn’t do this, once the keyboard is called it will not disappear.

On displaying alerts:

Setting up the display alert function with a title and message allows you to call it every time you need to grab the users attention. In this case we call the users attention when they have entered in information incorrectly. The alert allows you to set a title and message. It also allows you to set the title for the button/ buttons users can press to dismiss it.