Check full access for custom keyboard extension ipad

笑着哭i 提交于 2020-01-17 09:11:30

问题


I need to know whether allow full access has been toggle on or off for my keyboard extension. Following the answer in this: Check full access for custom keyboard extension I was able to get the check to work reliably for an iPhone but on an iPad (iPad 3 device) or any iPad simulators iOS 8.1 this always returns false.

Here is the code I am using from the above referenced SO answer:

-(BOOL)isOpenAccessGranted{

    NSFileManager *fm = [NSFileManager defaultManager];
    NSString *containerPath = [[fm containerURLForSecurityApplicationGroupIdentifier:@"mygrouppath"] path];

    NSError *err;

    [fm contentsOfDirectoryAtPath:containerPath error:&err];

    if(err != nil){
        NSLog(@"Full Access: Off");
        return NO;
    }

    NSLog(@"Full Access On");
    return YES;
}

How do i get reliable results on an iPad?


回答1:


I figured out a solution. Checking if the general pasteboard is available seems to be a very reliable way of checking if full access is on.

-(BOOL)isOpenAccessGranted{

    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    NSLog(@"pasteboard: %@", pasteboard);
    if(pasteboard){
        NSLog(@"Full Access On");
        return YES;
    }else{
        NSLog(@"Full Access: Off");
        return NO;
    }
}


来源:https://stackoverflow.com/questions/27466478/check-full-access-for-custom-keyboard-extension-ipad

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!