Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Temporary Disclaimer

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 ?

like image 728
cyberbemon Avatar asked Feb 16 '26 08:02

cyberbemon


2 Answers

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.

like image 59
Stuart Avatar answered Feb 17 '26 22:02

Stuart


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

like image 39
mja Avatar answered Feb 17 '26 20:02

mja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!