Can HTML5 localStorage in Cordova/Phonegap app be synced to iCloud?

给你一囗甜甜゛ 提交于 2019-12-04 16:33:33

The answer unfortunatly appears to be no, Core Data cannot be used with HTML5 localStorage

Core Data can not be used with SQLite databases other than ones created with Core Data. If you try to, you get this error in XCode:

SQLite error code:1, 'no such table: Z_METADATA'

This is explained the Core Data docs:

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdFAQ.html#//apple_ref/doc/uid/TP40001802-SW2

Although Core Data supports SQLite as one of its persistent store types, the database format is private. You cannot create a SQLite database using native SQLite API and use it directly with Core Data (nor should you manipulate an existing Core Data SQLite store using native SQLite API)

I still want to solve this issue though. I'm thinking of creating a Javascript API that mirrors the localStorage API. This would be a phonegap plugin that can call objective-c code, and effectively write it's changes to a Core Data database. The Core Data database should then be able to be synced to iCloud.

If it works, I'll come back and update this answer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!