Chapter 30
Working with Parse as Mobile Backends

Some of your apps may need to store data on a server. Take the TripCard app that we developed in the previous chapter as an example. The app stored the trip information locally using an array. If you were building a real-world app, you would not keep the data in that way. The reason is quite obvious: You want the data to be manageable and updatable without re-releasing your app on App Store. The best solution is put your data onto a backend server that allows your app to communicate with it in order to get or update the data. Here you have several options:

  • You can come up with your own home-brewed backend server, plus server-side APIs for data transfer, user authentication, etc.
  • You can use CloudKit (which was introduced in iOS 8) to store the data in iCloud.
  • You can make use of a third-party Backend as a Service provider (BaaS) to manage your data.

The downside of the first option is that you have to develop the backend service on your own. This requires a different skill set and a huge amount of work. As an iOS developer, you may want to focus on app development rather than server side development. This is one of the reasons why Apple introduced CloudKit, which makes developers' lives easier by eliminating the need to develop their own server solutions. With minimal setup and coding, CloudKit empowers your app to store data (including structured data and assets) in its new public database, where the shared data would be accessible by all users of the app. CloudKit works pretty well and is very easy to integrate (note: it is covered in the Beginning iOS Programming with Swift book). However, CloudKit is only available for iOS. If you are going to port your app to Android that utilizes the shared data, CloudKit is not a viable option.

Parse is one of the BaaS that works across nearly all platforms including iOS, Android, Windows phone and web application. By providing an easy-to-use SDK, Parse allows iOS developers to easily manage the app data on the Parse cloud. This should save you development costs and time spent creating your own backend service. The service is free (with limits) and quick to set up.

If you haven't heard of Parse, it is better to understand its history.

Parse was acquired by Facebook in late April 2013. Since then, it has grown into one of the most popular mobile backends. Unfortunately, Facebook considered to shut down the service and no longer provides the Parse cloud to developers. For now, you can still use Parse as your mobile backend. It comes down to these two solutions:

  1. Install and host your own Parse servers - Although the Parse's hosted service will be retired on January 28, 2017, Facebook released an open source version of the Parse backend called Parse Server. Now everyone can install and host their own Parse servers on AWS and Heroku. The downside of this approach is that you will have to manage the servers yourself. For indie developers or those who do not have any backend management experience, this is not a perfect option.
  2. Use Parse hosting service - Some companies such as SashiDo.io and Back4App now offers managed Parse servers. In other words, they help you install the Parse servers, and host them for you. You do not need to learn AWS/Heroku or worry about the server infrastructure. These companies just manage the Parse cloud servers for you. It is very similar to the Parse hosted backend provided by Facebook but delivered by third-party companies. In this tutorial, I will use Back4App's Parse hosting service, simply because it is free to use. After you understand how

In this chapter, I will walk you through the integration process of Parse using Back4app. We will use the TripCard app as a demo and see how to put its trip data onto the Parse cloud. To begin with, you can download the TripCard project from http://www.appcoda.com/resources/swift59/ParseDemoStarter.zip.

If you haven't read chapter 29, I highly recommend you to check it out first. It will be better to have some basic understandings of the demo app before you move on.

I hope I have made everything clear. Let's get started.

To continue reading and access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.

results matching ""

    No results matching ""