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;
Community
  • 1
  • 1
Khant Thu Linn
  • 5,905
  • 7
  • 52
  • 120
  • 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. – Mark Johnson Oct 17 '14 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 '14 at 10:20

2 Answers2

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

nurnachman
  • 4,468
  • 2
  • 37
  • 40
  • 1
    Checking if the shared user folder also works, i.e. containerURLForSecurityApplicationGroupIdentifier – jjxtra Oct 04 '14 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. – Mark Johnson Oct 17 '14 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. – Mark Johnson Oct 17 '14 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 – benjamin.ludwig Nov 12 '14 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
}
guest
  • 11
  • 1