ios - 只能通过wifi连接到CloudKit的公共(public)容器,但不能通过蜂窝连接

标签 ios swift cloudkit

确实缺乏有关 CloudKit 公共(public)容器的文档和信息。我遇到的问题是,设备连接到蜂窝网络时无法发送数据,但连接到 Wifi 时却可以正常工作。

let publicCloudDatabase = CKContainer.default().publicCloudDatabase
let operation = CKModifyRecordsOperation(recordsToSave: [exampleRecord], recordIDsToDelete: nil)
let operationConfiguration = CKOperation.Configuration()

operationConfiguration.allowsCellularAccess = true
operationConfiguration.qualityOfService = .userInitiated
operation.configuration = operationConfiguration

operation.perRecordProgressBlock = {(record, progress) in
    print(progress)
}

operation.perRecordCompletionBlock = {(record, error) in
    print("Upload complete")
}

publicCloudDatabase.add(operation)
publicCloudDatabase.save(exampleRecord) { [unowned self] record, error in
    if let error = error {
        print("public cloud database error: \(error)")
    } else {
        print("Sucessfully uploaded to Public Cloud DB")
    }
}

我不断收到一条错误消息:

CKError 0x281ff9ec0: "Network Unavailable" (3/NSURLErrorDomain:-1009); "The Internet connection appears to be offline."

当我的设备上的蜂窝网络连接绝对不是问题时。

最佳答案

我想知道这是否是设备上的设置。您是否检查过 iCloud Drive 是否允许使用蜂窝数据?

在您的 iPhone/iPad 上,前往设置 > 蜂窝网络 > iCloud Drive(位于底部;确保其已开启)。

关于ios - 只能通过wifi连接到CloudKit的公共(public)容器,但不能通过蜂窝连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63802055/

相关文章:

120 fps 的 iOS Metal 双缓冲

ios - openfire 中需要哪些插件才能进行聊天

ios - 从共享数据源中删除元素时,Swift CollectionView 会导致应用程序崩溃

ios - 将 "no segue with identifier"与 Storyboard引用一起使用时为 'Unwind Segue'

ios - 如何按字段和记录类型执行查询

ios - 如何修复 CloudKit Dashboard 中的 ZONE_NOT_FOUND 错误?

ios - 2 iAds 在模拟器上

ios - 当使用逗号而不是小数点时,我的 iOS 应用程序会计算数字吗?

ios - 为什么不将值user.username传递给导航器

ios - 如何使用 CKSubscription 检查 CKAsset 的变化?