-1

我正在使用 Swift 和 Xcode 13.1 编写一个 iOS 应用程序。我正在使用联系人框架,我读到每个应用程序都有一个默认的联系人容器,并且一个应用程序中的默认容器可以与另一个应用程序中的默认容器不同,并且整个设备没有默认容器。

什么决定了 Xcode 项目创建的应用程序的默认容器是什么?我没有为我的应用程序设置默认容器,并且不知何故,Google 帐户的联系人容器成为我的应用程序的默认联系人容器。如何使用代码为我的应用设置默认联系人容器?

如何找出 iOS 随附的 Apple 通讯录应用程序的默认容器?我想将我的应用程序的默认联系人容器设置为与 Apple 的联系人应用程序相同的默认容器,如果那是保存在 iCloud 上的联系人容器。如果没有,我想将我的应用程序的默认联系人容器设置为保存在 iCloud 中的联系人容器。我假设只有一个联系人容器保存在 iCloud 上。

4

1 回答 1

1

The user can specify the default contact container for new contacts in settings. Your app can access the identifier of this container using defaultContainerIdentifier.

If you want to allow the user to specify a different container for new contacts created by your app, then you need to code that yourself.

You need to provide a view that displays the list of contact containers resulting from a call to containers(matching:nil). Once the user selects a container, store its identifier in your apps preferences and use that container identifier when you create new contacts.

All you can know about a container is its identifier, its name and its type (Exchange, CalDAV or local).

于 2021-12-09T02:14:01.320 回答