简体   繁体   English

如何在我的Cocoa Touch应用中实施“首次用户注册”工作流程?

[英]How can I implement a “first time user registration” workflow in my Cocoa Touch app?

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. 用户首次登录时,我想让他们完成一个4步骤的注册过程,以创建其用户名,设置其个人资料照片等。每个步骤将是一个不同的屏幕。

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"? 它们应该是UINavigationController以便将其实现为“堆栈”吗? ie 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 (ie 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? 有没有一种方法可以存储已完成的步骤数,因此,如果numStepsCompleted == 0那么我知道它们尚未启动,如果numStepsCompleted < 4我知道它们已经启动但尚未完成?

In general, if there are any code examples online that implement something like this, it would be great to look at. 通常,如果在线上有任何代码示例实现了这样的功能,那么最好看一下。

Thanks! 谢谢!

I would present a UINavigationController modally from you root view controller. 我将从您的根视图控制器模态地呈现一个UINavigationController。 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. 保存在NSUserDefaults中,用户已经完成注册过程。 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. 如果这是第一次启动,请显示注册/登录过程,如果不是,则从钥匙串中获取用户名和密码。

Save a value in NSUserDefaults to know which is the last completed step done by the user. 在NSUserDefaults中保存一个值,以了解哪个是用户完成的最后一步。 As tou said, make a UINavigation to setup the four registration steps. 正如头说的那样,进行UINavigation来设置四个注册步骤。 When the app opens read the user defaults to know if the registration is finished. 当应用打开时,用户默认会知道注册是否完成。

There are a couple of different ways to implements this: 有两种不同的方法可以实现此目的:
1. Use a UINavigationController 1.使用UINavigationController
2. Use a UIPageViewController (which I like better) 2.使用UIPageViewController (我更喜欢)
3. Use a UITableView to contain all the information in one screen 3.使用UITableView在一个屏幕中包含所有信息

To keep track of the registration info you should implement a RegistraionInfo class (or struct in Swift). 为了跟踪注册信息,您应该实现RegistraionInfo类(或Swift中的struct)。 Since there should only be one instance of it, you can create a singleton and access it from anywhere - RegistrationInfo.sharedInstance() 由于应该只有一个实例,因此您可以创建一个单例并从任何地方访问它RegistrationInfo.sharedInstance()

You can also create an instance in the first ViewController and pass it to the next one on prepareForSegue: . 您还可以在第一个ViewController中创建一个实例,并将其传递给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 . 否则,您可以在NSUserDefaults保留一个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将 pod(第三方框架)添加到我的自定义可可触摸框架中? - How can i add pod(third party framework) into my custom cocoa touch framework? 如何实现“可可触摸框架”组件的弹出窗口? - how to implement popover for 'cocoa touch framework' component? 如何在Cocoa Touch中保存网站并将其存储在数组中? - How can I save a website in Cocoa Touch and store it in an array? 如何使用Cocoa Touch动态创建UIButton? - How can I dynamically create UIButtons with Cocoa Touch? 如何在iPhone应用程序中实现特定用户的Instagram照片/​​提要? - How can I implement Instagram photos/feed from a specific user in my iPhone app? 如何告诉我的应用忽略特定的触摸? - How can I tell my app to ignore a specific touch? 如何检查用户是否首次访问我的iOS应用? - How to check if user visit my iOS app for the first time? 无法使用Cocoa Touch Framework存档应用 - Can't archive app with Cocoa Touch Framework 每当用户从App Store购买我的iOS应用程序时,如何获得通知? - How can I get notified every time a user purchases my iOS app from the App Store? 我的可可触摸应用程序中的按钮未正确返回我的位置 - My button in cocoa touch app is not returning my position correctly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM