Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check "Allow Full Access" is granted since iOS 8.3 *from the container app*

Prior to iOS 8.3, the way to check whether "Allow Full Access" was granted to a keyboard extension was through the following code in the container app:

- (BOOL)isOpenAccessGranted{
   return [UIPasteboard generalPasteboard];
}

However, as comments on this popular SO answer thread point out, since iOS 8.3, an app can read from shared group containers even if full access is not granted, so the above code always returns true. However, write permission is granted only if "Allow Full Access" is turned on.

I have tried listing out all of the pasteboards based on Apple's docs on UIPasteboard, but it does not delineate which ones are accessible. Any insights on this is much appreciated.

like image 243
daspianist Avatar asked Jul 19 '15 02:07

daspianist


2 Answers

Here's my currently working / deployed implementation:

- (void)viewDidAppear:(BOOL)animated {
    NSLog(@"keyboard has full access? %@", ([self validateKeyboardHasFullAccess] ? @"YES" : @"NO"));
}

- (BOOL)validateKeyboardHasFullAccess {
    return !![UIPasteboard generalPasteboard];
}
like image 125
Yup. Avatar answered Oct 22 '22 20:10

Yup.


On iOS 8.4 the UIPasteboard.generalPasteboard() is nil if Full Access is not allowed. Try removing keyboard and container app + clean and build app, before testing again. Should work fine.

like image 1
Omar Avatar answered Oct 22 '22 19:10

Omar