如何在 XamarinMac 上请求联系人和日历权限?

How to request Contacts and Calendar Permissions on XamarinMac?

我正在尝试访问 MacOS 应用程序的 ContactStore,做了以下实现

public void Contacts()
{
    //Starting
    var store = new CNContactStore();

    store.RequestAccess(CNEntityType.Contacts, async (bool granted, NSError error) =>
        {
            if (granted)
            {
                //Query things
            }
        });
}

问题是 Authorize screen 永远不会弹出,而 Permission 总是说拒绝。

如果我转到设置以删除该记录,则该应用不存在。

谁能给我指点光?

这两行对我有用:

            var contactStore = new CNContactStore();
            var status = CNContactStore.GetAuthorizationStatus(CNEntityType.Contacts);

也可能你需要在info.plist中设置NSContactsUsageDescription