How can I migrate my user-generated data to the computer? - iphone

I have a query regarding BackUp of third party application data on PC.
I am developing an application which can store photos, text, recordings.
The user can add number of photos or recordings.
So at the runtime, size of application storage will go on increasing.
User will never want to loose his data but storage is limited.
Hence taking backup of data on his computer and then deleting from iPhone seems essential.
So what is the standard way of taking backup of third party application data?
Is there any way by which we can save the data on MAC as well as Windows using iTunes?
Is there any limit on amount of storage a third party application can take?

iTunes will perform a complete backup of the iPhone when it is plugged in for sync, which will contain all the application-specific data files. However, the only way to restore this is to restore the entire system image, so that is only an emergency backup, not what you need.
Third parties have typically provided their own backup and synchronisation strategies. There are two broad approaches:
in conjunction with a companion desktop version of the same application (eg. OmniFocus, Things, Four Track)
using a web service (eg. Darkslide for Flickr)
The web services are typically accessed via an AJAX API (or equivalent), but will obviously take longer for backups of large files. The desktop sync products provide their own (eg. OmniFocus uses a WebDAV server) and use an internal sync engine to keep things up to date, and can sync using the WiFi connection.
So either way, you are most likely going to have to write your own server to handle your own backups, and deal appropriately with the file types and metadata. I don't know of a third-party solution to this, but if one exists, it would be very generic, and may not suit your particular needs (eg. for file formats, etc).
So what is the standard way of taking backup of third party application data?
Write your own sync server and connect via WiFi. Start by looking at WebDAV, as you can build something on top fairly easily.
Is there any way by which we can save the data on MAC as well as Windows using iTunes?
iTunes will only do a full system backup. Your best bet is to write your sync server to be portable.
Is there any limit on amount of storage a third party application can take?
AFAIK there is no per-application storage limit on the iPhone. If you provide your own solution, you could do something like archive anything older than 30 days onto the Mac/PC, so you are only keeping recent files. Then allow them to choose "favourites" and those will be kept on the iPhone regardless of age.

You can use iTunes to back up your iPhone. During the process of transferring the iPhone data, you will be asked to back up apps. But if your apps are not from iTunes library, you may not install them when you restore them on devices.

Related

Syncing data to iPad from iPhone

I want to sync data between iPhone and iPad. I am using core data and save the data in Documents of Document Container. Since Documents is backed up by both iTunes and iCloud. Since iCloud is deprecated in latest version of Xcode. Do I have to do anything else to sync data between these iOS devices?
Backups are not a sync mechanism. For one thing, backups are device specific. Data that gets backed up from someone's iPhone is not available to their iPad. There is no device-to-device data mixing through backups.
Putting the persistent store file in iCloud (via the iCloud file API) is not workable either. You can't just read/write the file in iCloud directly, you need to download the file first and later upload changes. Core Data isn't designed to work in that scenario. You might write code to do it, but the data would become corrupted almost immediately because Core Data isn't expecting you to mess with the persistent store like that.
If you want to sync data between devices, there are many options. Apple offers CloudKit, which is free and supported by Apple. Firebase is popular. Parse servers are still extremely common even though Parse itself is shutting down. Add to that Microsoft Azure and many, many others.

iPhone (iOS) app using local sqlite and desire to sync between multiple devices

I have an iPhone (iOS) app that keeps data in a local SQLite database on each device. The app is used to manage a virtual bank account for kids to track their allowance, spending, savings, etc. (KidsBank and KidsBank Free). I am getting a lot of requests from parents to provide a sync capability between parents and possibly even their children's iOS devices.
I have considered several options, but all are tedious and non-trivial since this basically requires database replication or a new architecture. Any transaction on any device ideally should appear (sync) to all devices in the family (as immediately as possible).
Ideally, I would like the sync to be automatic & hands off
Options include
(1) Use of iCloud
(2) Use a direct network connection between devices (wifi)
(3) Use of a server side database and web service (JSON/RESTFul)
(1) iCloud
PRO: iCloud provides distributed file sync
CON: iOS 5 required, SQLite database files can not be synced via iCloud, classic database replication (and non-trivial)
Using iCloud is a strong consideration. Devices can write a custom transaction log to an iCloud file where there is one file for each device identified by a unique device ID. Global unique ids (GIDs) and last change timestamps are added to each table. All participating devices will write a unique device ID to a separate file in iCloud. Upon app launch or upon log file change, the app running on a specific device will load all transactions but not those generated on their own device from the files via iCloud. The last participating device to load the transaction will remove the transaction from the file. If the device is not the last participating device, it simply signs off on the transaction and allows the file to sync via iCloud. There may be better algorithms, but the basic idea is the same - using iCloud to push around change logs.
(2) A direct wifi connection will allow two devices to manually sych.
PRO: Not as complicated to manage the sync process
CON: Users must both select to sync from their apps while connected on wifi
(3) Move the entire database or manage transactions on a server.
PRO: Sync is no longer required
CON: Typical issues for a web-driven app. Would need to rewrite the database service layer (currently in SQL) to use a remote web service. Cost of running a server (I would use AWS).
Can anyone offer some experience in syncing SQLite between multiple devices? I'm leaning in the direction of using iCloud to push around transaction logs. I'm trying to minimize cost and complexity.
Moving to iCloud is probably the best solution, as it is proven and made by Apple. You don't need to worry to much about the iOS 5 requirement, as according to most stats over 90% use it. iOS 5 is free to upgrade to. You could then rename your old version as Lite, and continue without syncing.
Syncing is probably one of the hardest things you do.
One solution I made is that all changes to a database leave a log, with timestamp, uniqueid and couple of other things to make sure the transaction is totally anonymous and totally unique. I have made an extremely simple web service that has two operations, you can add transaction to it, so I sync whenever the user is on wifi, so I push all changes, receive a result from the server, then delete the transaction records as they are synced.
The other action is to fetch the records, send the timestamp of last sync, userid and other.
All data is sent using JSON and received as such. It can easily handle tens of thousands of users, running on a small Amazon EC2 server.
This is pretty much how iCloud works, but I made this solution before iCloud. Now I am going to iCloud, but probably need to keep the server running for 1 more year or so, depends on usage.
Hope this helps you.
After finding time to get back to working on the app and also with time passing and Core Data iCloud replication maturing, I converted my app to Core Data (NSSQLiteStoreType) and monitor notifications such as persistentStoreDidImportUbiquitousContentChanges. Using lightweight migrations too. Working well.

Need iOS Database Cloud Design Tips

I have an app that uses an SQLite database. With the advent of iCloud on the rise I'm trying to figure out a good architecture for syncing data between devices. So lets say my app runs on an iPhone, an iPad, and a Mac. How can I keep data in my DB up-to-date on all devices?
My first thought was, I can put the database in the cloud and send transactions. But the device may not always been online and the users need their content at anytime, so that wont work. My other thought was to continue using the local db, and then when a connection is made, to send the cached data to the central db. The problem is I have no ideal where to even begin on something like that. How would I know which data has been sent and not sent, which data to actually send when a connection is made, etc.
So this is my question (we don't have to get into iCloud specifics), using an SQLite database and iCloud (or any storage medium), how can I sync data between multiple devices, but still have the most recent data stored locally on the device?
You might want to checkout Couchbase Mobile. This would help with the synchronization you are looking for.
If you have a significant investment into CoreData, then you may want to look at writing your own NSIncrementalStore to support writing data to and from a key value store.
iCloud is only going to be a good solution if your data is sandboxed to a specific user. If you have multiple users that want to view the same data then it won't work.

how to synchronize coredata between devices?

i have an iphone app that uses coredata to store its contents. users often ask me if i could provide a way to sync data between their mobile devices (ipod/iphone/ipad). as of now, i have no idea on how to achieve this.
i found zsync, but this seems to depend on a osx version of the app (which i dont have). i also read about upcoming iclouds sync features, and it seems to be what i need - however i think its not possible to sync coredata contents, but text-based contents only (e.g. xml storage files). is this true?
another way i was thinking of was to abuse the eventkit api to sync via a user-provided calendar. since my app is mainly managing events, which can optionally be stored in a user-calendar (in addition to coredata storage), syncing through a calendar would seem good to me. however i think syncing might break, e.g. when the user chooses not to syncronize the whole calendar but only like 3 months in the devices settings/account settings.
anyone got an idea of how my approach should be like? any tips?
Syncing device to device (if that is what you are trying to achieve) can be quite tricky. You could implement your own discovery and data-transfer protocol and work something out that way, but it could be quite a bit of work.
Syncing device to server to device is a bit more straightforward, assuming that you already have a server with some form of registration/login system. Then you just need a way of communicating your current database state up to the server, and then back down again from the server to other devices. Again there is a fair bit of work involved in doing this, but at least the logic of working out which devices sync with which other devices and how they transfer data from one to the other is all implicit in the workings of the server.
As for iCloud, the programmatic content that you sync through it needs to be derived from UIDocument, so it will not help you with generic Core Data entities.
If you're looking for an out-of-the-box solution that will sync all of your Core Data content from one device to another with no custom code, then there really isn't one. The closest you can reasonably get would be to ship the entire .sqlite file that your app uses from one device to another, overwriting the target devices .sqlite file. That works fine if your sync only needs to be unidirectional, but obviously is not appropriate for other use-cases. Perhaps you could use this model with iCloud, if you can get it to sync your app's entire .sqlite file as an atomic entity.

iPhone Data Storage - understanding what is and what is not secure

I am developing my first iPhone application and currently considering whether to deploy the app packaged with data, instead of calling upon a web service for the info. The obvious benefits are for those situations where you have a poor/non-existent connection and i could easily write something that could update the client data periodically from within the app.
What i am not sure about is how to store the data - sqlite, core data, plist or iphone file structure - Simply because i dont want someone unzipping the deployed application and getting their hands on the raw data.
Is this actually feasable? or is pretty much everything accessible once its deployed as an app?
You cannot stop somebody from accessing the data stored on the device, independently if you use sqlite, core data, plist or iphone file structure. At least not within reasonable means.
What you can do rather easily is to make the data useless for unauthorized access. In other words: encrypt it.
If what format you store the encrypted data then depends on the app needs.
This is pretty tough to do. The easiest way to do this would be by using the Xcode Organizer panel and then looking at the applications that you have installed. If it is one of your applications (matching your dev credentials) then Xcode will give you the option to download the application's sandboxed folders (docs, temp, etc).
From memory, you cannot do this to another application that doesn't belong to you. So in short you are safe to include data in your app. Honestly though, if someone wants to get to that data, they always will given enough time and resources (thats my opinion about all security).