【问题标题】:Flow for setting up a social component in an app using 100% CloudKit and SwiftUI?使用 100% CloudKit 和 SwiftUI 在应用程序中设置社交组件的流程?
【发布时间】:2021-05-12 01:25:01
【问题描述】:

我有一个应用程序已经使用 CloudKit 在 iPhone 和 Apple Watch 应用程序之间传递信息。我想添加让用户与其他用户共享保存在 iCloud 中的数据的功能。到目前为止,我还没有找到任何好的资源。我的理解是Apple recommends 使用UICloudSharingController 设置共享逻辑,但这需要包含在UIHostingController 中以用于SwiftUI。我找到了this answer,但发布的代码使用了一些自定义属性,例如ObjectToShare,我无法理解它们是如何设置的。我必须使用UICloudSharingController 吗?我可以让一个用户获得自己的 shareURL 并将其发送给另一个用户吗?如果是这样,用户 1 将如何获得自己的 shareURL?

【问题讨论】:

    标签: ios swiftui icloud cloudkit cloudkit-sharing


    【解决方案1】:

    您不必使用UICloudSharingController,不。您可以手动设置自己的CKShare 对象。它有一个url 属性,用户需要单击该属性才能访问您正在共享的CKRecord。因此,您可以以自定义方式显示url,也可以随意传递它。

    CKShare 文档显示了所有可用的属性: https://developer.apple.com/documentation/cloudkit/ckshare

    这篇文章有点老了,但它帮助我看到了设置CKShare的整体过程:https://kwylez.medium.com/cloudkit-sharing-series-creating-the-ckshare-40e420b94ee8

    【讨论】:

    • 非常感谢,在我的原始帖子之后我已经走这条路了,但遇到了一个障碍,让userDidAcceptCloudKitShareWith 使用UIApplicationDelegateAdaptor 开火请参阅:stackoverflow.com/questions/67541441/… 任何想法?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-26
    • 1970-01-01
    相关资源
    最近更新 更多