简体   繁体   English

检测我的应用程序是否具有全盘访问权限

[英]Detect whether my app has Full Disk Access

Before prompting the user to grant FDA to my app, I have to know whether I already have it.在提示用户将 FDA 授予我的应用程序之前,我必须知道我是否已经拥有它。

What's a reliable way to check this?什么是检查这个的可靠方法?

Note: I used to check for access to ~/Library/Safari/Bookmarks.plist , but on a fresh 10.14 system, this file may not even exist, thereby now allowing me to check whether I can access it.注意:我曾经检查对~/Library/Safari/Bookmarks.plist的访问,但在一个新的 10.14 系统上,这个文件甚至可能不存在,因此现在允许我检查我是否可以访问它。 Same issue with checking for Calendar or Contact database files.检查日历或联系人数据库文件的问题相同。

I ran into this need myself and discovered PermissionsKit .我自己遇到了这种需求并发现了PermissionsKit They too were looking at ~/Library/Safari/Bookmarks.plist - they changed it to use ~/Library/Safari/CloudTabs.db in 10.15.他们也在查看~/Library/Safari/Bookmarks.plist - 他们在 10.15 中将其更改为使用~/Library/Safari/CloudTabs.db In macOS 12 I found that file no longer exists in fresh installs so they now use ~/Library/Application Support/com.apple.TCC/TCC.db (the Transparency, Consent, and Control database, so hopefully this doesn't go away so easily!).在 macOS 12 中,我发现该文件不再存在于全新安装中,因此他们现在使用~/Library/Application Support/com.apple.TCC/TCC.db (透明度、同意和控制数据库,所以希望这不会发生这么容易就走了!)。 They've actually updated it to check multiple files so should be more reliable.他们实际上已经对其进行了更新以检查多个文件,因此应该更可靠。

It's a shame there isn't an API to determine our access state and we have to resort to such fragile solutions.很遗憾没有 API 来确定我们的访问状态,我们不得不求助于如此脆弱的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM