Search code examples
objective-cios8ios-app-extensioncustom-keyboardios-app-group

Check full access for custom keyboard extension


I need to check full access for custom keyboard extension. I found this link.

How to check the "Allow Full Access" is enabled in iOS 8?

It say we can check App group. I have app group called "group.TTT.TGroup". It share access between main app and custom keyboard.

Then, I check like this. Problem is that I always have access to that (always has array or error = null). Is it because I am sharing same data? But, if my app use another app group and extension use other app group, I can't definitely access to that. May I know how to do?

NSFileManager* fileManager = [NSFileManager defaultManager];
NSString *path = [fileManager containerURLForSecurityApplicationGroupIdentifier:@"group.TTT.TGroup"].path;
NSError *error;
NSArray *arr = [fileManager contentsOfDirectoryAtPath:path error:&error];

NSLog(@" arr is %@",arr);
if (arr == nil || !arr) //can check error also
    accessOn = NO;

else accessOn = YES;

Solution

  • You can try reading a value from the shared NSUserDefaults - if the value is null, then allowFullAccess is off

    Or you can try reading files from the shared file system using containerURLForSecurityApplicationGroupIdentifier