How can I check if a custom ios8 keyboard extension has public access?

In my ios 8 keyboard extension, I want to check if the user has given access to the open keyboard or not. But I could not find the API. Swiftkey and other custom keyboards somehow solve this problem.

+5
source share
5 answers

There is no API, but if you have access to the application group enabled, you can try to check whether you can read / write to the folder. It should give you access to access permissions not included.

+3
source

I think this is easier (no need to create a container):

- (BOOL) isOpenAccessGranted { if ([UIPasteboard generalPasteboard]) return YES; return NO; } 
+5
source

Use it

 -(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; } 
+2
source

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 answer with live saving here

How to check "Allow full access" and "Allow full access". is included in iOS 8?

I tested several applications and it works great!

0
source

You can use this function to verify that your custom keyboard extension is public 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 } } } 
0
source

Source: https://habr.com/ru/post/1203468/


All Articles