Use case for offline data storage keeping in sync with Parse backend - ios

I am currently working on Parse integration for one of my iOS applications where in I need to pull some records (Customer Feedback from existing table) from Parse and show them in mob-app.With Parse iOS SDK 1.6.1 I realized that I could also use LocalDataStore to provide include the offline support, however going through the following articles appCoda , raywenderlich and Parse documents I could not figure out a solution which could solve the use case I am dealing with.
Step 1: Show all records pulling from server (Initially Sync - but I also realized that I need to enable [Parse enableLocalDatastore]; which is now interfering with initial data pull )
Step 2: Allow user to perform certain modification and sync this data back with server.
Step 3:Keep the local data store in sync with online data all the time (provided I have internet as and when needed).
I was able to implement the ALL-ONLINE version of the app and achieve all features as needed but I would also like to include the Offline support. A few question that raises doubt are
does LocalDataStore only support offline usage of the application that
has to be manually synced with Parse backend ?
The data fetch from Parse localDataStore via [query fromLocalDatastore]; doesn't return anything on first call (I know because there isn't anything on device). Do I need to write the logic to pull down data from backend every time and keep local datastore in sync ?)
Can someone correct me if I am using it the wrong way? or give me some pointers for correct usage, then it will be really helpful.

Yes, you have to query the data online first(without "[query fromLocalDatastore];"). And "pin' it for local usage.
Usefull hint can be to use "UpdatedAt" to get only the new stuff.
Once done, you can get data online and offline. The sync should be automatic.
'Red flag' : Don't forget to update to sdk 1.6.2, as they solve a lot of big bugs related to LocalDataStore.

Related

What type of database should I use in diary app in ios?

It is also the first time to develop,
I want to make a diary app, but I don't know which database to use because I don't have basic knowledge of the database.
When I click on the calendar, I would like to post on that date
And I also need a picture that needs to be imported.
I can look for it even if I post this. I think it would be the fastest to ask. Thank you for reading my POST and hope everyone who reads has a nice day
Quick Answer: I would recommend persisting data on the users device instead of a cloud based database by using Core Data for the following reasons:
The content may be private or sensitive in nature, keeping it on the device is safer
Media attachments can become costly at scale, saving to device removes that burden from the developer
some cons of this route include the following:
Potential loss of Analytics by not using a cloud database such as Google Firebase
Cloud storage can be backed up in case the user loses their device (assuming they are not backed up via iCloud)
For a more thorough answer I recommend you provide more in terms of your objectives and audience.

Parse to Firebase Database Migration

Still my app uses Parse for storing user details for my existing application, since Parse announced that shutdown date for their service, we planned to use Firebase,
Shall we import parse users into my Firebase framework, if yes please suggest way to migrate parse to Firebase.
This question is not easy to answer on stack overflow completely since it highly depends on what your data is like and what your source code is like. The first question I would have is why are you not using the suggested migration path which is using open source parse-server and mongodb?
If you do actually switch to firebase, then Frank's link is a great place to start. Switching from parse to firebase will not be a 5 minute process however, since the backends are completely different (although they seem very similar on the surface).
You can retrieve all your data from parse, including the user collection by going to the parse dashboard - App Settings - Export App Data. This will export JSON files of all your classes. You can find a way to import this into Firebase, but this will be done offline and then (if your app is live), the data will not be synchronized between the 2 backends.
The link suggests 2 approaches for this:
Migrate Your Data
After you decide how to structure your data in Firebase, you need to
plan how to handle the period during which your app needs to write to
both databases. Your choices are:
Background Sync
In this scenario, you have two versions of the app: the old version
that uses Parse and a new version that uses Firebase. Syncs between
the two databases are handled by Parse Cloud Code (Parse to Firebase),
with your code listening to changes on Firebase and syncing those
changes with Parse. Before you can start using the new version, you
must:
Convert your existing Parse Data to the new Firebase structure, and
write it to the Firebase Realtime Database. Write Parse Cloud Code
functions that use the Firebase REST API to write to the Firebase
Realtime Database changes made in the Parse Data by old clients. Write
and deploy code that listens to changes on Firebase and syncs them to
the Parse database. This scenario ensures a clean separation of old
and new code, and keeps the clients simple. The challenges of this
scenario are handling big datasets in the initial export, and ensuring
that the bidirectional sync doesn't generate infinite recursion.
Double Write
In this scenario, you write a new version of the app that uses both
Firebase and Parse, using Parse Cloud Code to sync changes made by old
clients from the Parse Data to the Firebase Realtime Database. When
enough people have migrated from the Parse-only version of the app,
you can remove the Parse code from the double write version.
This scenario doesn't require any server side code. Its disadvantages
are that data that is not accessed is not migrated, and that the size
of your app is increased by the usage of both SDKs.

Core Data Sync With Multiple Users

I would like to sync a core data app with a user with a different iCloud ID and I am trying to figure out the most graceful way to do this. I do not want the data to sync with all users, but want to be able to sync among family members for instance. From the research I have done, I do not think I can do that using iCloud Core Data sync because it only syncs between devices with the same iCloud ID. I have looked at this stackoverflow answer and read a little bit about Ensembles, Parcelkit and TICoreDataSync, Parse etc., but it is not clear to me if any of those options will allow me to sync with multiple users. Does anyone have a good method for syncing a Core Data app with multiple users?
Ensembles and TiCoreDataSync might work. They can use Dropbox file syncing, so in principle they should work with Dropbox shared folders. I don't think these are the main intended uses, so I suggest contacting the developers and/or doing some good testing yourself before assuming this would actually work.
You'll need to think about the user experience, though. At a minimum, your users would both need Dropbox accounts and would have to set up a shared folder before beginning to sync data this way.
Parcelkit probably won't work. It uses Dropbox's data store API which, unlike other Dropbox services, doesn't appear to support shared data.
Services that do support this kind of sharing exist-- for example, Parse and Firebase-- but make sure to review their pricing carefully before using them. Also of course, there have been any number of projects that have their own custom server back end, but that obviously requires having someone on the team who can do that kind of work.
You need to think about other device types (Android at least) if you want your application to be reaching more users.
I'm doing the same now by the following way:
Setup an online database with proper web services (careful with implementation for security matters - DB should NEVER be exposed by anything other than the web services).
Create a Class for your communication with the server (using Class methods with security handling like authentication and authorisation).
Use the class in your app to communicate with the server (SQL operations are done on the server).
To integrate with CoreData you need to create the model in your app similar to the structure in the backend database. Then you need to create a similar class for the app that deals with only local CoreData.
A higher level class might be required if you want to make sure that operations done on both server and local data storage.
Besides, you have to implement a lot of conditions to make sure that data written in local ONLY after making sure that it is stored online (or create an engine for differed operations to run later).
Another Way if you are familiar with notifications:
Use structured notifications between devices for data operations in order to keep everything in sync with other users. The problem with this is the "Autonomy" of the operations. If two operations were done in approximately the same time, you have to find a way to make sure the order of the operations is done properly (maybe timestamp or something).
I'm looking into the same thing for my app and I 'think' you can do a fairly unsecured version of what you are after using using the public folder in cloud kit as mentioned in this question (no accepted answer at time of posting) : Private data sharing using CloudKit
You would need to find a way to differentiate between data that is truly public and those shared among the users you need and some level of authentication.
I'm going to try exporting a permission file with access permission in it to whomever I want to share with combined with a unique identifier located in that permission file.
Keep in mind, as mentioned in the comments of the linked answer, my implementation will be security by obscurity (thanks for that phrase) unless you find a way of adding proper validation to it but my data is relatively insensitive.
Hope this, or any ridicule in the comments, points you in the right direction : )

iOS backend service manual data storage

I've searched about best iPhone backend services and best recommended are parse.com, stackmob... But what I'm interested is which one is best for storing own data by hand and then using that data for iOS ?
As I read the docs on all of these sites they are always refering to saving games data or any other data from the iPhone to the backend. But I would like to store my own data manually (so on www.parse.com website for example) on that backend and then use it/retrieve it on iPhone. Is that good aproach? Are those backends even used for those kind of stuff or should I create my own database for that?
If they are used, which one is the best? From all the recommendations and reviews looks like parse.com is prolly the best one.
Thanks.
Hmm, manually typing into Parse.com could be tedious although it is allowed with a clean UI. I suggest you put all your data in an Excel sheet, write an Excel formula to generate CURL commands and run the CURL command in a terminal that would save the data to your Parse.com account.
https://www.parse.com/docs/rest#objects-creating
EDIT
This question is old and parse.com is dead but there are many more options now.
Firebase
Use Swift Vapor/Perfect to create your own backend on AWS
Parse.com is good you can update data manually in parse.com table.
steps create parse.com account-> create your app -> click on the dashboard-> left side click to add class analogous to table-> add rows in your class manually or through API->fill data in columns.
Best part you don't have to pay till you generate enough traffic. so if your app is not a success you save on back-end development.
If on a later date you want higher capacity you can upgrade or you can export your database and port it to your own server.

Synchronization with RestKit

I'm about to write a simple iPhone app that uses Core Data to store local copy of remote data that is fetched via RESTful web service. The data changes (new records being added) quite often. I came across RestKit and I'm wondering if it can do what I need. And what I need is to load all records in the beginning and then periodically download ONLY records that were added since previous check. Obviously there is no mystery about how that can be accomplished even by simply using NSURLConnection, but I hoped RestKit (probably in combination with a proper web service) would do that without me having to write all the synchronization logic. Again the key for me is that only new/changed data is fetched from the server.
I agree - RestKit can do this, we've recently used it to do something similar in a recent project. We used a last-modified-date request header to indicate the last successful 'sync' time, which the server can use to return only the records modified since that date. A http 304 'not modified' status code was used to indicate no change when appropriate.
RestKit also includes a seeding facility, so you know up front the initial data set - you can seed it as the initial database easily, and fetch the updates, even upon first use of the application.
Some information I found useful regarding RestKit & CoreData mapping - https://github.com/RestKit/RestKit/blob/master/Docs/Object%20Mapping.md, and the Google group is a good source as well - https://groups.google.com/group/restkit. Hope this all helps.
First of all: YES
RestKit handles CoreData very well. All you need to do is to provide mapping of your entities and it does the work for you.
For the second thing about selective sync, I really recommend checking StorageRoomApp it is a great, and not so expensive service that does exactly what you need.
They have a very good API that extends RestKit, it is very easy to use and their support is great. Take a look.

Resources