简体   繁体   English

我可以在 Android 或基于网络的应用程序上使用 CloudKit 吗?

[英]Can I use CloudKit on Android or web-based app?

I've been coding an app, and using CloudKit would make my life a lot easier.我一直在编写一个应用程序,使用 CloudKit 会让我的生活变得更轻松。 However, this app needs a web-base app along side the iOS app.但是,此应用程序需要与 iOS 应用程序一起使用的基于 Web 的应用程序。 I was wondering if there was any way I could use CloudKit with Android or web-based apps.我想知道是否有任何方法可以将 CloudKit 与 Android 或基于 Web 的应用程序一起使用。

While this might not directly possible with an API provided by Apple, another possibility would be to use OS X Server for CloudKit.虽然这可能无法通过 Apple 提供的 API 直接实现,但另一种可能性是使用 OS X Server for CloudKit。 Would that be possible too/comply with Apple's Terms of Service for CloudKit?这是否也可能/符合 Apple 的 CloudKit 服务条款?

Yes you can.是的你可以。 Apple provides CloudKit JS , specifically designed for web services. Apple 提供了CloudKit JS ,专为 Web 服务而设计。 I don't know much about Android, but I'm pretty sure it'll be not a hard challenge to run JavaScript.我对 Android 了解不多,但我很确定运行 JavaScript 不会是一项艰巨的挑战。

Also CloudKit WebServices could be interesting for you. CloudKit WebServices也可能对您感兴趣。

EDIT advice and discussion编辑建议和讨论

To give you an honest advice: Better use something "own".给你一个诚实的建议:最好使用“自己”的东西。 I currently work with a custom server on an AWS EC2 instance and am really happy.我目前在 AWS EC2 实例上使用自定义服务器,我真的很高兴。

You could, for example, write a really simple server using Node.js and connect a Mongo DB NoSQL database.例如,您可以使用Node.js编写一个非常简单的服务器并连接一个Mongo DB NoSQL 数据库。 CloudKit is actually not more than this. CloudKit其实还不止这些。

This is really a simple task.这确实是一项简单的任务。 I did this before and with some JavaScript experience and a few days Node exercises it is absolutely feasible;我之前做过这个,有了一些JavaScript经验和几天的 Node 练习,这是绝对可行的; you'll write really nice servers very quickly.你会很快写出非常好的服务器。

In the end, when dealing with more customers, CloudKit will be more expensive, actually.最终,当与更多客户打交道时,CloudKit 实际上更贵。 And if you, why ever, must move to a different service, you will have trouble with CK, because you are not able to access the privately stored data.如果您,为什么必须转移到不同的服务,您将遇到 CK 问题,因为您无法访问私人存储的数据。

Also, be sure that CKs concept fits your needs.此外,请确保 CKs 概念符合您的需求。 I was in your situation a few months ago.几个月前我遇到了你的情况。 As I read more about CloudKit and viewed some WWDC sessions, I more and more realised that it is not a BAAS as you would probably expect.当我阅读更多关于 CloudKit 并查看一些 WWDC 会议时,我越来越意识到它不是您可能期望的 BAAS。

One example: You have no access control: private or public, thats it.一个例子:你没有访问控制:私人或公共,就是这样。 There is a public database which everyone can access each resource in. And a private one for any user, which is inaccessible by others.有一个公共数据库,每个人都可以访问其中的每个资源。还有一个供任何用户使用的私有数据库,其他人无法访问。

If you don't want to, or can't, do something on your own, you could simply use BAASBOX for self-hosted APIs or just any commercial BAAS .如果您不想或不能自己做某事,您可以简单地将 BAASBOX 用于自托管 API 或任何商业BAAS


EDIT II 编辑二

To point that out again for anyone late in the game:再次向比赛后期的任何人指出这一点:

The private (per-user) databases are absolutely inaccessible for others – even you as the developer and operator can't access the, most probably encrypted, data to move to a different (maybe self-hosted) service.其他人绝对无法访问私有(每用户)数据库 - 即使您作为开发人员和运营商也无法访问最有可能加密的数据以移动到不同的(可能是自托管的)服务。

You'd need to make an update and the app then needs to move the data to your new service on the users behalf – "device-ly".您需要进行更新,然后应用程序需要代表用户将数据移动到您的新服务——“设备层面”。

These kind of processes are typically problematic because you'd need to run two services until all active users moved their data – which is REALLY hard to tell;这些类型的过程通常是有问题的,因为您需要运行两个服务,直到所有活跃用户都移动了他们的数据——这真的很难说; your customer might be idle for some time and they'd be upset if their data is lost in void forever.您的客户可能会闲置一段时间,如果他们的数据永远丢失,他们会感到不安。

Ok – Cloudkit might continue until... Yeah, until then .好的 – Cloudkit 可能会一直持续到...是的,直到那时 So it might not be as problematic to do that kind of passive longterm-movement.因此,进行这种被动的长期运动可能没有那么大的问题。

Unfortunately CloudKit is only available for the Apple ecosystem.不幸的是,CloudKit 仅适用于 Apple 生态系统。 However, there are similar technologies called Parse and FireBase that allows you to do the same, but can be cross platform.但是,有一些类似的称为ParseFireBase 的技术可以让你做同样的事情,但可以跨平台。 However, they cost a lot more and are not client-side services.但是,它们的成本要高得多,而且不是客户端服务。

NOTE - Parse's hosted services will be fully retired on January 28, 2017.注意 - Parse 的托管服务将于 2017 年 1 月 28 日完全停用。

Use CloudKit JS to build a web interface that lets users access the same public and private databases as your CloudKit app running on iOS or macOS.使用 CloudKit JS 构建一个 Web 界面,让用户可以访问与在 iOS 或 macOS 上运行的 CloudKit 应用程序相同的公共和私有数据库。

You must have an existing CloudKit app and enable web services to use CloudKit JS.您必须拥有现有的 CloudKit 应用程序并启用 Web 服务才能使用 CloudKit JS。

for Set up your app's containers and configure CloudKit JS do following step by step:要设置应用程序的容器并配置 CloudKit JS,请按以下步骤操作:

  1. Create your app's containers and schema.创建应用的容器和架构。

    If you are new to CloudKit, start by reading CloudKit Quick Start .如果您不熟悉 CloudKit, 请先阅读CloudKit 快速入门 You'll use Xcode to create your app's containers and use CloudKit Dashboard to view the containers.您将使用 Xcode 创建应用程序的容器并使用 CloudKit 仪表板查看容器。 Then create an iOS or Mac app that uses CloudKit to store your app's data.然后创建一个使用 CloudKit 来存储应用程序数据的 iOS 或 Mac 应用程序。

  2. In CloudKit Dashboard, enable web services by creating either an API token or server-to-server key.在 CloudKit 仪表板中,通过创建 API 令牌或服务器到服务器密钥来启用 Web 服务。

  3. Embed CloudKit JS in your webpage.在您的网页中嵌入 CloudKit JS。

    Embed CloudKit JS in your webpage using the script tag and link to Apple's hosted version of CloudKit JS at https://cdn.apple-cloudkit.com/ck/2/cloudkit.js .使用脚本标签将 CloudKit JS 嵌入到您的网页中,并在https://cdn.apple-cloudkit.com/ck/2/cloudkit.js链接到 Apple 托管的 CloudKit JS 版本。

    <script src="https://cdn.apple-cloudkit.com/ck/2/cloudkit.js">

The CloudKit JS version number is in the URL. CloudKit JS 版本号在 URL 中。 For example, 2 specifies CloudKit JS 2.0.例如,2 指定 CloudKit JS 2.0。

  1. Enable JavaScript strict mode.启用 JavaScript 严格模式。

    To enable strict mode for an entire script, put "use strict" before any other statements.要为整个脚本启用严格模式,请将“use strict”放在任何其他语句之前。

    "use strict";

  2. Configure CloudKit JS.配置 CloudKit JS。

    Use the CloudKit.configure method to provide information about your app's containers to CloudKit JS.使用 CloudKit.configure 方法向 CloudKit JS 提供有关应用程序容器的信息。 Also, specify whether to use the development or production environment.另外,指定是使用开发环境还是生产环境。 See CloudKit for an example, and see CloudKit JS Data Types for details on the CloudKit.CloudKitConfig properties you can set.有关示例,请参阅 CloudKit,有关可以设置的 CloudKit.CloudKitConfig 属性的详细信息,请参阅 CloudKit JS 数据类型。

Now you can use the CloudKit.getDefaultContainer method in your JavaScript code to get the app container (CloudKit.Container) and its database objects (CloudKit.Database).现在,您可以在 JavaScript 代码中使用 CloudKit.getDefaultContainer 方法来获取应用程序容器 (CloudKit.Container) 及其数据库对象 (CloudKit.Database)。

ref lineks:参考线:

Cloud kit quick Start 云套件快速入门

Accessing CloudKit Using an API Token 使用 API 令牌访问 CloudKit

CloudKit Web Services Reference CloudKit 网络服务参考

Accessing CloudKit Using a Server-to-Server Key 使用服务器到服务器密钥访问 CloudKit

CloudKit Catalog: An Introduction to CloudKit (Cocoa and JavaScript) CloudKit 目录:CloudKit 简介(Cocoa 和 JavaScript)

iCloud Design Guide iCloud 设计指南

Ref Page:参考页面:

CloudKit JS CloudKit JS

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 android 工作室中从基于 Web 的应用程序打印? - Printing from Web-based App in android studio? 我可以在android设备上创建一个基于Web的演示并离线发布吗? - Can I create a Web-based demo on an android device and deliver it offline? 作为API播放框架。 我是否可以使用基于Web的应用程序和Android本机作为Client端使用Rest Api直接与Play进行交互 - play framework as an API. And can I use web-based application and native Android as Client side to directly interact with Play using Rest Api 在基于Web的应用程序中,如何在基于Web的应用程序URL的末尾调用用户的IMEI / UDID? - In web-based apps, how do I call a user's IMEI / UDID to the end of my web-based app's URL? 是否可以将基于网络的移动应用提交到Android Market或App Store? - Is it possible to submit web-based mobile apps into the Android Market or App Store? 事件跟踪器是基于 Web 还是基于应用程序? - Web-based or App-based for an Events-tracker? 我应该怎么做才能在loadUrl中使用http构建基于网络的脱机Phonegap应用 - What should I do to build an offline web-based Phonegap app using http in loadUrl 使用本机导航编写基于Web的移动应用程序可行吗? - Is it viable to write a web-based mobile app with native navigation? 基于Android网络的模拟器Manymo,它是如何工作的? - Android web-based Emulator Manymo, how does it work? 从基于网络的市场在Android上远程安装应用 - Remotely install apps on android from the web-based market
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM