3

I'm making an app as a part of my project and I've been asked to add a disclaimer.

At first I made a separate view with a textview that holds the disclaimer, when the user presses the Disclaimer button they will see this.

But I've been asked to change this so that the disclaimer is shown if the app is being used for the first time. If the user accepts it, they won't see it again and if they don't they'll see it every time they open the app.

I don't know how to go about this. I tried changing it so that the first thing the app shows when launched is the disclaimer, but that got annoying because every time I launch the app it goes to the disclaimer.

Anyone have any suggestions or examples ?

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
cyberbemon
  • 3,000
  • 11
  • 37
  • 62
  • 1
    possible duplicate of [iphone: the quickest easiest way to detect first launch](http://stackoverflow.com/questions/308832/iphone-the-quickest-easiest-way-to-detect-first-launch) – mmmmmm Sep 20 '11 at 20:50

3 Answers3

3

You can use NSUserDefaults to achieve this. Once the user has accepted the disclaimer, write a BOOL called disclaimerAccepted (or similar) to your defaults. Use the following code in the AppDelegate method application:didFinishLaunchingWithOptions: to check this:

if (![[NSUserDefaults standardUserDefaults] boolForKey:@"disclaimerAccepted"]) {
    // Show the disclaimer.
}

And use this code when the user accepts the disclaimer:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool:YES forKey:@"disclaimerAccepted"];
[defaults synchronize];

Hope this is helpful.

Stuart
  • 36,683
  • 19
  • 101
  • 139
1

Why not use NSUserDefaults to store info whether user dismissed or accepted the disclaimer & show the dialog accordingly. NSUserDefaults are persisted even if app is closed.

edit:

Here is an example Using User Defaults

mja
  • 5,056
  • 1
  • 29
  • 40
0

The best solution I found is given here: iPhone: How do I detect when an app is launched for the first time?

If you like it add your upvote there - I only just used it a couple of days ago and I think it is really good!

Community
  • 1
  • 1
user387184
  • 10,953
  • 12
  • 77
  • 147