检查自定义键盘扩展ipad的完全访问权限 [英] Check full access for custom keyboard extension ipad

查看:190
本文介绍了检查自定义键盘扩展ipad的完全访问权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道是否已为我的键盘扩展程序打开或关闭允许完全访问权限。以下答案如下:检查自定义键盘扩展的完全访问权限我能够使检查能够可靠地用于iPhone但是在iPad(iPad 3设备)或任何iPad模拟器iOS 8.1上,这总是返回false。

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.

这是我在上面提到的SO答案中使用的代码:

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;
}

如何在iPad上获得可靠的结果?

How do i get reliable results on an iPad?

推荐答案

我想出了一个解决方案。检查一般的粘贴板是否可用似乎是一种非常可靠的方法来检查是否已启用完全访问。

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;
    }
}

这篇关于检查自定义键盘扩展ipad的完全访问权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆