问题
I need to know whether allow full access has been toggle on or off for my keyboard extension. Following the answer in this: Check full access for custom keyboard extension I was able to get the check to work reliably for an iPhone but on an iPad (iPad 3 device) or any iPad simulators iOS 8.1 this always returns false.
Here is the code I am using from the above referenced SO answer:
-(BOOL)isOpenAccessGranted{
NSFileManager *fm = [NSFileManager defaultManager];
NSString *containerPath = [[fm containerURLForSecurityApplicationGroupIdentifier:@"mygrouppath"] path];
NSError *err;
[fm contentsOfDirectoryAtPath:containerPath error:&err];
if(err != nil){
NSLog(@"Full Access: Off");
return NO;
}
NSLog(@"Full Access On");
return YES;
}
How do i get reliable results on an iPad?
回答1:
I figured out a solution. Checking if the general pasteboard is available seems to be a very reliable way of checking if full access is on.
-(BOOL)isOpenAccessGranted{
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
NSLog(@"pasteboard: %@", pasteboard);
if(pasteboard){
NSLog(@"Full Access On");
return YES;
}else{
NSLog(@"Full Access: Off");
return NO;
}
}
来源:https://stackoverflow.com/questions/27466478/check-full-access-for-custom-keyboard-extension-ipad