从服务器端数据库到 iPhone 进行单向同步的最佳方法是什么?
我的服务器上有一个大约 3mb 大的数据库。我想将其与我的 iPhone 应用程序一起发送。
最重要的是我想将对数据库的更改(插入、更新、删除)推广到iphone。最好的方法是什么?我的意思是 - 需要什么 - 服务器 - 客户端(= iPhone) - 之间;如何传输这些数据?
我可以很自由地使用服务器端技术;现在,我在服务器上有一个 sqlite 数据库,其中包含我想要同步到 iPhone 的数据。
I've got a database on my server which is about 3mb big. I'd like to ship that with my iphone application.
The most important thing is that I'd like to promote changes to the database (insert, updates, deletes) to the iphone. What's the best way of doing that? I mean - what is necessary on
- the server
- the client (= iphone)
- between; how to transfer this data?
I'm pretty free in using technologies serverside; right now, I've got an sqlite-database on the server filled with the data I'd like to sync to the iphones.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要多久更新一次数据库,更改的紧急程度如何?
如果数据库更新不频繁且不紧急,我会让应用程序在启动时检查数据库的新版本,如果已更改,则下载整个新文件。
该应用程序始终会在启动时从已知 URL 下载一个小型元数据文件。元数据文件包含最新版本的版本标识符以及可以下载该版本数据库的位置。如果版本标识符与应用程序已有的版本相比发生了变化,将下载新版本。如果版本标识符未更改,或者无法检查,则应用程序可以继续使用其现有版本。
专业提示:如果您想显示下载进度条,请在元数据文件中包含数据库的大小。蜂窝网络通常具有透明代理,可以从 HTTP 响应中去除 Content-Length 标头。
How often do you need the database to be updated, and how urgent are the changes?
If the database updates are infrequent and non-urgent, I'd have the app check for a new version of the database on startup, and if it has changed, download the entire new file.
The app would always download a small metadata file from a known URL on startup. The metadata file contains an version identifier for the latest version and a location where that version of the database can be downloaded. If the version identifier has changed from the version the app already has, will download the new version. If the version identifier has not changed, or if it can't check, the app can keep using the version it has.
Pro tip: if you want to show a progress bar for the download, include the size of the database in the metadata file. Cell networks often have transparent proxies that strip out the Content-Length header from HTTP responses.
尝试使用网络挂钩。
您可以在此处找到有关 Webhooks 的更多信息:
http://www.webhooks.org/ 和 http://webhooks.pbworks.com/
Try using web hooks.
You can find out more on Webhooks here:
http://www.webhooks.org/ and http://webhooks.pbworks.com/
想知道您是否考虑过使用同步框架来管理同步。如果您对此感兴趣,可以查看开源项目 OpenMobster 的同步服务。您可以执行以下同步操作:
除此之外,所有修改都会自动跟踪并与云端同步。当网络连接断开时,您可以让应用程序离线。它将跟踪任何更改,并在连接恢复时自动在后台将其与云同步。它还提供像 iCloud 一样跨多个设备的同步功能
。此外,云中的修改是使用推送通知进行同步的,因此即使数据存储在本地,数据也始终是最新的。
以下是开源项目的链接:http://openmobster.googlecode.com
这里是 iPhone 的链接应用程序同步:http://code.google.com/p/openmobster/wiki/iPhoneSyncApp< /a>
Wonder if you have considered using a Sync Framework to manage the synchronization. If that interests you can take a look at the open source project, OpenMobster's Sync service. You can do the following sync operations
Besides that, all modifications are automatically tracked and synced with the Cloud. You can have your app offline when network connection is down. It will track any changes and automatically in the background synchronize it with the cloud when the connection returns. It also provides synchronization like iCloud across multiple devices
Also, modifications in the Cloud are synched using Push notifications, so the data is always current even if it is stored locally.
Here is a link to the open source project: http://openmobster.googlecode.com
Here is a link to iPhone App Sync: http://code.google.com/p/openmobster/wiki/iPhoneSyncApp