featured-image-ios

Create Log In User and Session Check for iOS Mobile App using Mesosfer – Part 3

In this tutorial, we will learn how to Create Log In User and Session Check for iOS Mobile App using Mesosfer Backend as a Service. Download all code:

ios-objective-cios-swift

1. Introduction

This is the third session of tutorial series. You can read the previous session here. In this section, we’ll create simple iOS Log In User and Session Check based on  Mesosfer Documentation.

2. Prerequisites

To follow the step in this tutorial, you should set up some prerequisites below:

  • Sign up for an account in Mesosfer Backend as a Service.
  • Install the latest Xcode. In this tutorial, the author used Xcode 8.1 (8B62).
  • You can download the code from previous session here.

3. Getting Started

3.1. Designing views

Create a log in view on your Main.storyboard like below :

login-view-storyboard

  • Email Address (UITextField), used for entering login email credential.
  • Password (UITextField), used for entering login password credential.
  • Login (UIButton), used for executing login to the Mesosfer Cloud.
  • Register (UIButton), used to navigating to the register view.
  • Optional : Add a Logo (UIImageView) of your app to the top of login view.

Here is the complete storyboard of this session tutorial :

part-3-complete-storyboard

  1. Splash (UIViewController), a static view that used for checking a user session. If there is a user session, it will show main view. Otherwise it will show login view.
  2. Main (UITableViewController embedded in UINavigationController), used for displaying main menu if there is a user session.
  3. Login (UIViewController), used for logging in a user.
  4. Register (UITableViewController embedded in UINavigationController), used for signing up a user.

3.2. Referencing the outlets

Add LoginViewController class to your Xcode project, then add referencing outlet for each object library :

Objective-C

Swift

3.3. Completing the codes

3.3.1. LoginViewController complete code :

Objective-C

  • .h file

  • .m file

Swift

3.3.2. Rename ViewController to SplashViewController. We will use this class to check user session, complete code :

Objective-C

  • .h file

  • .m file

Swift

Don’t forget to change the class name for splash view controller in Interface Builder -> Identity Inspector.

3.3.3. Create MainViewController. We will use this class to display main menu if there is a user session. For this tutorial, main class show a menu to logging out user, complete code :

Objective-C

  • .h file

  • .m file

Swift

4. Conclusion

We’ve already created log in and session check module in iOS mobile app. It’s an easy way for developers. So enjoy creating your Mobile application using Mesosfer Backend as a Service. Mesosfer helps you connect your project to the cloud. Cut off the development process so you can straight into the delivery process instead stumble on the complicated infrastructure.

Lead Mobile Software Engineer. Having more than 8 years in IT Consultant. Love working with new mobile platform technology. Expert in Android and iOS Mobile Development.