In my ios 8 keyboard extension I wanna check did user gave my keyboard open access or not. But I couldn't find any API. Swiftkey and other custom keyboards somehow solve that problem
Asked
Active
Viewed 2,179 times
5 Answers
5
I think this is an easier way (no need to create a container):
- (BOOL) isOpenAccessGranted
{
if ([UIPasteboard generalPasteboard])
return YES;
return NO;
}

Clément Choquereau
- 111
- 2
- 7
4
There is no API, but if you have app group access enabled, you can try to check if you are able to read/write to the folder. It should give you a permission error access is not enabled.

honcheng
- 2,014
- 13
- 14
2
Use this,
-(BOOL)isOpenAccessGranted
{
NSFileManager *filemanager = [NSFileManager defaultManager];
NSString *containerPath = [[filemanager containerURLForSecurityApplicationGroupIdentifier:@"/***YOUR APP GROUP ID***/"] path];
NSError *err;
[filemanager contentsOfDirectoryAtPath:containerPath error:&err];
if(err != nil)
{
NSLog(@"Full Access: Off");
return NO;
}
NSLog(@"Full Access On");
return YES;
}

Thangavel
- 216
- 2
- 10
-
some more details: http://stackoverflow.com/questions/25472388/how-to-check-the-allow-full-access-is-enabled-in-ios-8 – fisch2 Nov 20 '14 at 23:05
1
Pasteboard API changed in iOS10 beta
Swift:
func isOpenAccessGranted() -> Bool {
let originalString = UIPasteboard.general.string
UIPasteboard.general.string = "TEST"
if UIPasteboard.general.hasStrings {
UIPasteboard.general.string = originalString
return true
}else{
return false
}
}
Found this live-saving answer here
How to check the "Allow Full Access" is enabled in iOS 8?
I tested a few apps and works perfect!

Community
- 1
- 1

Jorge Irún
- 1,683
- 1
- 15
- 13
-
any reason for downvote? if there's something wrong here would be good if you could explain.. – Jorge Irún Sep 06 '16 at 17:50
-
0
You can use this function to check your custom keyboard extension have open access or not:
func isOpenAccessGranted() -> Bool{
if #available(iOS 10.0, *) {
let originalString = UIPasteboard.general.string
UIPasteboard.general.string = "Sour LeangChhean"
if UIPasteboard.general.hasStrings {
UIPasteboard.general.string = originalString ?? ""
return true
}else{
UIPasteboard.general.string = ""
return false
}
} else {
// Fallback on earlier versions
if UIPasteboard.general.isKind(of: UIPasteboard.self) {
return true
}else{
return false
}
}
}

Sour LeangChhean
- 7,089
- 6
- 37
- 39