How to determine that the user launches the application for the first time?

I recently had a problem with my iOS application. In my application, the instruction view will be displayed for the first time, and then hide it. How can I realize this effect?

+6
source share
4 answers

Try using this function:

- (BOOL) isFirstRun { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; if ([defaults objectForKey:@"isFirstRun"]) { return NO; } [defaults setObject:[NSDate date] forKey:@"isFirstRun"]; [[NSUserDefaults standardUserDefaults] synchronize]; return YES; } 
+20
source

On your delegate, check the key in the user default settings (your own custom key, something like "AppWasAlreadyStartedPreviously"). If the key does not already exist, this is the first run. You can show your presentation of the instruction and add the key to the default values ​​for the user. The next time the user launches the application, you will find the key in the default settings and know that it is not the first.

See the NSUserDefaults documentation.

+5
source

Save the file and check if the exsist file exists every time the application starts. If the tr file is not exsists then enter intro and then create the file.

+1
source

The only way I consider storing the value in the specified file when starting the application is to first check the value, and then you can decide whether the application will already be running.

0
source

Source: https://habr.com/ru/post/919201/


All Articles