您可以在不同的应用程序之间共享CloudKit上的数据吗? [英] Can you share data on CloudKit between different apps

查看:141
本文介绍了您可以在不同的应用程序之间共享CloudKit上的数据吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用商店中有免费且付费的应用版本。我正在更新应用程序以使用CloudKit共享一些公共数据。我希望免费和付费应用分享相同的数据。

I have a free and paid version of my app in the app store. I'm updating the app to share some public data using CloudKit. I'd like both the free and paid apps to share the same data.

首先,两个应用可以与CloudKit共享相同的数据吗?

Firstly is it possible for two apps to share the same data with CloudKit?

如果是这样,我怎样才能让它发挥作用?我尝试在两个目标的功能中启用CloudKit,并在两个应用程序中选择相同的容器。选择使用默认容器的主应用程序工作正常,但我选择指定自定义容器并从第一个目标中选择自定义容器的另一个应用程序在我尝试下载任何内容时收到错误。

If so, how can I get this to work? I've tried enabling CloudKit in the capabilities of both targets and selecting the same container in both apps. The main app which has 'Use default container' selected works fine, but the other app, on which I've selected 'Specify custom containers' and selected the custom container from the first target, gets an error back when I try to download anything.

推荐答案

是的,多个应用可以使用相同的CloudKit数据。当你得到你的CKContainer时,我假设你在两个应用程序中都使用类似的东西?

Yes, multiple apps can use the same CloudKit data. When you get your CKContainer, I assume you are using something like the following for both apps?

let container = CKContainer.defaultContainer()

这适用于主应用程序(具有与cloudkit标识符匹配的包标识符的应用程序) 。其他应用程序需要像这样初始化容器:

This would work for the main app (the one with the bundle identifier that matches the cloudkit identifier). The other app(s) will need to initialize the container like so:

let container = CKContainer(identifier: "iCloud.com.example.appname")

这篇关于您可以在不同的应用程序之间共享CloudKit上的数据吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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