I开发者_如何转开发 am very confused. How can display agreement page only once in time of use of application.I don't how can i explain this .But I am trying to explain this . I am creating the application in which i have the agreement page which has the two button (1)Button name is Accept (2)Button name is Reject
If user click the Accept button application enter into the next page But when the user click on the Reject button application exit out from the application . But the twist is here If user run this application first time he see the agreement page and if user accept this agreement then only then after he move farther .But when user use this application again and again he must not see the agreement page again and again if he already accept the agreement. Please help me out how can i solve this I am very confused. thanks in advance
YOU CAN Apply the Agreement Page through The Alter View
and
If User Accept the Agreement than You Store The Value of Agreed(Possibly Bollean) in the plist file(possibly from document directory of the app) than each time you can check it
CODE FOR TO NOT TO Display Agreement If it is accepted For once
add one plist file in to resource folder
Add one boolean variable in plist Set Value AS UNCHECKED(REJECTED STATE)
//Copy the plist to document directory
-(void)CopyPlistTODocument
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath= [documentsDirectory stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager fileExistsAtPath:writableDBPath];
if (success) return;
// The writable database does not exist, so copy the default to the appropriate location.
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Settings.plist"];
success = [fileManager copyItemAtPath:defaultDBPath toPath:writableDBPath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@'.", [error localizedDescription]);
}
}
//NOW Call Another method that read data form plist of document directory
-(void)desclaimer
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"setting.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
BOOL *temp=[plist valueForKey:@"Agreement"];
//if the value of the temp got YES That Agreed earlier so no need to agreed again
if ([temp isEqualToString:@"NO"])
{
//Show Alert View From Here And call Method Accept() on the button pressed event of the accept button
}
}
//Now From Button Pressed Event Of The Accept Here is the Accept method
-(void)Accept
{
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectoryPath = [paths objectAtIndex:0];
NSString *path =[documentsDirectoryPath stringByAppendingPathComponent:@"Settings.plist"];
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile: path];
[plist setValue:@"YES" forKey:@"Agreement"];
//now every time the value read from here has agreed state so alert view will not get called
[plist writeToFile:path atomically:YES];
}
The best solution is to put this license agreement when you are sending your app to iTunes Connect , it have a place specially for that.
so if the user disagree he will not install the app in the first place
Check "EULA" part of "iTunesConnect DeveloperGuide" page 52
hope it helped you.
精彩评论