I have been looking at this whole Apple Parental Gate issue and trying to come up with a simple solution for iOS. So instead of creating a whole SDK, I decided to implement this simple parental gate using a UIAlertView.
Please leave a comment with regards to whether or not Apple accepts your app with this gate in it.
-(void)parentalGate{
//Parental Gate
NSString *pgQuestion = @"";
int pgTag = 0; //7771 7772 7773
int pgAnswer = (arc4random() % 3) + 1; //Choose random interger between 1 and 3
if (pgAnswer == 1) {
pgQuestion = @"PARENTAL GATE:\nHow many of the following\nnumbers are divisible by 3?\n1, 2, 3, 4, 7, 8";
pgTag = 7771; //correct answer is 1
} else if (pgAnswer == 2) {
pgQuestion = @"PARENTAL GATE:\nHow many of the following\nnumbers are divisible by 3?\n2, 3, 4, 5, 6, 7";
pgTag = 7772; //correct answer is 2
} else {
pgQuestion = @"PARENTAL GATE:\nHow many of the following\nnumbers are divisible by 3?\n3, 4, 6, 7, 8, 9";
pgTag = 7773; //correct answer is 3
}
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:pgQuestion message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
alertView.tag = pgTag;
[alertView show];
[alertView release];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == 7771 || alertView.tag == 7772 || alertView.tag == 7773) {
//Parental Gate
if (buttonIndex == 1) { //OK button
int parentalGateAnswer = [[[alertView textFieldAtIndex:0] text] intValue];
if ( (alertView.tag == 7771 && parentalGateAnswer == 1) || (alertView.tag == 7772 && parentalGateAnswer == 2) || (alertView.tag == 7773 && parentalGateAnswer == 3) ) {
NSLog(@"==Parental Gate SUCCESS");
} else {
NSLog(@"==Parental Gate Incorrect Answer");
}
} else if (buttonIndex == 0) { //Cancel button
NSLog(@"==Parental Gate Cancel");
}
}
}
You can also download it from here:
https://www.iwebss.com/wp-content/uploads/2013/10/ParentalGate-UIAlertView.txt