JustPaste.it

Google: Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the Apache 2.0 License. For details, see our Site Policies.

For more information about the code, see: http://www.cookiechoices.org/ 

For iOS:

=======

 

// This code will work in iOS 2 and up
// (spoiler: you're not going to need anything below iOS 6).
// Tested in iOS 7
// In your app's UIApplicationDelegate:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { (...) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if (![defaults boolForKey:@"termsAccepted"]) {
NSString *message = @"Your message for visitors here"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cookies" message:message delegate:self cancelButtonTitle:nil otherButtonTitles:@"Close message", nil]; [alert show]; } }

// Elsewhere in the file: - (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setBool:YES forKey:@"termsAccepted"]; [defaults synchronize]; }