1

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;
2
  • I think its a case of the Simulator not behaving the same as the device. Without full access, you can't read files in the shared app group folder. But you can on the simulator. Oct 17, 2014 at 15:50
  • what is main app ? i just tried to disabled main app share app group and still can check full access
    – TomSawyer
    Nov 10, 2014 at 10:20

2 Answers 2

5

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

4
  • 1
    Checking if the shared user folder also works, i.e. containerURLForSecurityApplicationGroupIdentifier
    – jjxtra
    Oct 4, 2014 at 16:53
  • 1
    Note, on simulator you can read files from the shared app group folder, even if full access is off. But on the device full access off means no file access. Oct 17, 2014 at 15:51
  • Also note, after you turn on Full Access, you may need to restart the app using the keyboard to get it to notice the change. Oct 17, 2014 at 15:53
  • 1
    This works for the extension, but the hosting app can always read from the shared container. is there a way to get this information from within the hosting app Nov 12, 2014 at 13:40
1
+(bool)fullAccessAccessible{
    NSUserDefaults *myDefaults = [[NSUserDefaults alloc]
                              initWithSuiteName:APP_GROUP_NAME];
    NSString* test_key = @"extension test full access";
    [myDefaults setBool:TRUE forKey:test_key];
    BOOL res = [myDefaults boolForKey:test_key];
    return res == TRUE;//set and get compare
}
1
  • what you are trying to say?? explain it.
    – Kumar
    Aug 5, 2015 at 11:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.