R
R
Roman Gor2017-03-05 13:41:44
iOS
Roman Gor, 2017-03-05 13:41:44

What is the correct controller view mechanism?

Foreword:
I am a web developer trying to get my head around iOS development.
Problem:
When loading an application, the authentication service must check for the presence of an authorization token, and depending on the result (the token exists or not), redirect to the required controller:
1. If the user is not logged in, show the login screen;
2. If the user has a token, show the profile screen;
Question:
What is the most effective mechanism for solving this problem?
In my opinion, the mechanism should be as follows:
MainCotroller, which is a NavigationView, when loading, the service is polled and, depending on the result, pushes the desired controller.
This option seems the most obvious and correct. But since I don't have enough experience in mobile app development, and I don't know best practices, I could be wrong.
I ask the community to help me in solving this problem.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2017-03-10
@briahas

1) Some controller (not NavigationController), let it be AuthController, is launched from the AppDelegate and processes the logic associated with the token.
2) Further, in the AppDelegate, upon request (isLoggedIn or isTokenAvailable, as you prefer) to an object of the AuthController class after its initialization, you get true or false
3) Depending on the answer in paragraph 2, you push either the LoginViewController or the HomeViewController to the NavigationController

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question