1

I'm implementing a "new user registration" in my app

The first time the user logs in, I'd like to have them complete a 4-step registration process to create their username, set their profile photo, etc.. Each step would be a different screen.

All this needs to be done just once. I was wondering -

  1. What is the best setup for these 4 screens? Should they be a UINavigationController so that they are implemented as a "stack"? i.e. the user can go back to the previous screens?

  2. How do I preserve the state of the registration? I'd like to know what step the user was on in case they leave halfway, or in general know whether I should display the registration (i.e. if this is their first time). Is there a way I can store the number of steps completed, so that if numStepsCompleted == 0 then I know they haven't started and if numStepsCompleted < 4 I know they have started but not finished?

In general, if there are any code examples online that implement something like this, it would be great to look at.

Thanks!

3 Answers 3

5

I would present a UINavigationController modally from you root view controller. One the user has finished you can do 2 things:

  1. Save in NSUserDefaults the fact that the user has already complete the registration process. If the user delete the app, this flag will be removed with it.
  2. Save personal information such username and password in the keychain, they will persist event after the remove of the application, that can be useful for silent login process and they are ciphered.

For the first point to can do something like that

+ (BOOL)isFirstTime{
    static BOOL flag = NO;
    static BOOL result;
    if(!flag){
        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"hasBeenLaunchedOnce"])
        {
            result = NO;
        }
        else
        {
            [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasBeenLaunchedOnce"];
            [[NSUserDefaults standardUserDefaults] synchronize];
            result = YES;
        }

        flag = YES;
    }
    return result;
}

If this is the very first launch, show registration/login process, if not go along by taking username and password from keychain.

2
  • Thanks for the example! I there a good way to "call a UINavigation Controller modally" as you mentioned? Mar 2, 2015 at 7:29
  • First create you navigation controller with its root view controller, than from a view controller (can be anyone) call [yourVC presentViewController:navVC animated:YES completion:NULL]
    – Andrea
    Mar 2, 2015 at 7:43
1

Save a value in NSUserDefaults to know which is the last completed step done by the user. As tou said, make a UINavigation to setup the four registration steps. When the app opens read the user defaults to know if the registration is finished.

0

There are a couple of different ways to implements this:
1. Use a UINavigationController
2. Use a UIPageViewController (which I like better)
3. Use a UITableView to contain all the information in one screen

To keep track of the registration info you should implement a RegistraionInfo class (or struct in Swift). Since there should only be one instance of it, you can create a singleton and access it from anywhere - RegistrationInfo.sharedInstance()

You can also create an instance in the first ViewController and pass it to the next one on prepareForSegue:.

The last part is to identify if the user already completed the Sign Up process. If you're using a Username/Password model then you should keep that info in the keychain and fetch it on launch.
Otherwise you can keep a value in NSUserDefaults.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.