Server Connection

Start course
Overview
Difficulty
Intermediate
Duration
3h 18m
Students
2
Description

In this course, we're going to build a Foursquare Clone using Parse. Parse provides you with a great tool to work in cloud servers and you will learn the advantages and disadvantages that come with it.

Intended Audience

This course is designed for anyone who wants to:

  • Learn about iOS development and coding
  • Move into a career as an iOS developer
  • Master Swift skills

Prerequisites

To get the most out of this course, you should have some basic knowledge of iOS.

Transcript

Hi. Within this lecture, we're going to create our own Back4App Server, and we're going to connect our Xcode project to our servers so that we can start working on our Parse project. So, go to 'back4app.com', and if you don't have any account, and I doubt you have, you can just register here by giving your email and password and saying, 'Create account'. And I already have a password and account here, so I'm going to come over here and give my email and password and say, 'Log in.' So, this will bring me to my dashboard and in my app so when you create your account, you will come here too.

So, I have a previous test app in here, but you won't see this, you will just see this new plus button, if you click over here, you can choose a new app name for yourself. So, I'm going to call this 'FirstsquareCloneiOS'. I'm going to say 'Create', and this will just create the database, the server, everything for me. Once it does that, and as you can see it's pretty fast, it takes me to this FirstsquareCloneiOS dashboard. So, this is my app and this is my database. So, this is kind of different when we compare it to the Firebase. We have everything in our database inhere. We don't have any authentication module, we don't have any storage module. We only have one database and we save everything in that database. Of course we can have more than one database classes or one database sheets or tables as you may wish. And it's different than SQL or SQL, and however you may want to pronounce it, but it's more close to the SQL when you compare it to the Firebase. So, we have these classes. And under these classes we have some columns, and under these columns we have some rows and values. So, for example, we have a default user database, and when we do authentication, it actually saves all the information in that database. We're going to see how this works. I'm just trying to take you over this dashboard, and I'm trying to get you familiarized with this dash board right now. And in the left-hand side, you'll see that rather than having an authentication and every other thing we have something called Cloud Code Functions.

If you want to run a cloud code in the cloud server, like a JavaScript code, you can use it. Of course, it's out of our scope in our course, but you can do that using Cloud Code Functions. And in here, you see we have configurations, API Console, and Logs and everything. And we're going to do a lot of configurations, don't worry. In the 'Admin App' tab, you get to see an admin application. So, if you build a good project or if you build a big project where you may want to give some administrator rights to nontechnical persons, nontechnical people, then you may use this administrator app. And this doesn't even exist in the original Parse Server. So, Back4App actually improved their self to create this.

So, we don't need this right now, so I'm not going to enable this. I'm not going to use this because we're going to see how to develop this as a technical person. So, we're going to see how to create, users, how to write to database, how to read from database using Swift code. So, I'm not going to do that but in real life, this may come in handy if you have a big project going on. So, here we have something called Push and this is related to push notifications. So, we have seen how to work with one signal, so I'm not going to use this. And you can use one signal with these Parse as well. So, this doesn't actually bring too much for me because I already know how to leverage push notifications. But if you don't want to use one signal for some reason, you're more than welcome to use this push notification section of the Parse platform as well.

And in AWS, in Amazon Web Services, push notifications do not work, but in Back4App, it works. So, in the analytics, we have the statistics of our app, like how many requests that we got, how many users signed in and everything. And in Server Settings and App Settings, we have the General settings. So, app settings are actually very brief. So, we have the App name, if we want, we can change it from here. We have the Collaborators. So, if you have like a team, you can just invite them writing their email, you can clean up the app and clean up the logs from here, but we are interested in the server settings right now. So, if you come over here, you will see a lot of settings regarding our own Back4App Server. So, if you come to your general settings over here, you will see something like App Id, App Name, the API Address and the version. So, we're going to need this information in order to connect our app to this server. So, these values are just created for you. By the way, you shouldn't actually share this information with other people but rather use that information in your own projects to connect your app to your Back4App server. So, that's what we're going to use to connect our Xcode project. But right now we don't know how to do it, right?

So, we have to get some sort of documentation to start with our process. So, this Back4App actually has great documentation as well. So, they provide everything in order to connect our app and get started. So, right now it's actually under these Guides in the Help menu, but maybe they will change the menu in time, but they have great documentation and I believe they will continue to have this. So, under iOS, we have a Swift Template. So, we can actually start with this template, but we don't need that because we already have created our own project, and brought in the Parse SDKs. I will just download it and show you how this is done anyway for later on if you want to start with this, but right now we're not going to use this Xcode project. And in here, you can see something like getting started and the GitHub repository of this current project. If you come over here to GitHub repository, it will download this project for you. And in fact, it's a great tool to copy and paste and get started with the Parse. For example, in the GitHub repository of the Parse itself doesn't have this documentation. So, I'm going to click over here and download it and show it to you anyway. So, if you come over here and click on this new Parse app tutorial, you will see how to create an app and to create a server like this.

So, we have already done that, so I'm going to close this down, rather, I'm going to go for this repository and download it. As you can see, it asks me if I want to download this, so I'm going to say 'Allow'. And don't worry if you cannot find this in documentation, it doesn't matter because we're not even going to use this. I'm just going to show you how you can use if you want, but I'm just going to write my own code from scratch anyway. So, if you come over here to QuickStartupExampleApp, we have this workspace file in here as well. If we double click on this, it will pop open and we can see the necessary code to integrate our Parse Server to our project.

And when you download some app from the Internet, make sure you run Putty install before you open this. But I'm not even going to use this, so I'm just trying to see the content of these Swift files, so I didn't bother doing it. As you can see in AppDelegate, we have some sort of configuration. In ViewController.swift, we don't have anything. So, this is kind of an old file, I believe it's created in iOS 11 or iOS 12. We are doing iOS 13 over here, so I'm not going to use this at all. But as you can see, we have some sort of configuration function in here, and configuration function in AppDelegate, and we don't have anything else in other ViewControllers. So, the same installation object is kind of a test function and we don't need it actually, but we need something like this. Before we actually load our ViewController, we have to configure our Parse using the application ID and other parameters that we're going to get from our server so that we can connect our project easily and smoothly with our Parse Server.

I'm not even going to copy and paste this in my own project, but again, you're more than welcome to do so. I'm going to show you how to do it from scratch. So, if you come over here, your AppDelegate.swift, you will see it did finish launching with options. And remember, in Firebase we did the configuration here as well. So, this is one of the first functions that is getting called when app first launches, right? So, after importing parse, we will be ready to create a configuration file for configuration variable for parse. So, I'm going to say, let configuration, and this configuration is actually going to be a ParseClientConfiguration, okay? So, as you can see this is the configuration to connect our sdk with our server. So, I'm going to come over and open the parentheses and it will give us a block. So, this is cool, we can just double click on this to have our ParseMutableClientConfiguration. So, mutable meaning it can be changed, okay? And we don't have anything else. So, I'm going to go for it. Once you do that, once you hit 'Enter' you can hit 'Enter' one more time to use this variable given to us. So, this is  a closure and we have seen closures before, right? And in here, we can just delete this and make it another closure, but just a regular variable and write our code like we have seen in the sample code as well but I'm not going to do that. I'm just going to use the ParseMutableClientConfiguration variable that is given to me in here. I'm going to say dot and we're going to choose three parameters from here to connect our app to our server. So, these three parameters are actually given us in the general settings of our servers. So, first of which is applicationId, okay? And the second one is clientKey, okay? And the last one is the server URL itself. So, it's called server. Once you do that, you can just initialize these values as empty strings for right now. Later on, we're going to get that and paste it in here. Once we do that, the configuration is ready and we can say parse.initialize and it will ask us as a ParseClientConfiguration variable, and we're going to give that as configuration, okay? So, that's it. That's all you have to do to connect your app to your server, and we have to get this applicationId clientKey. I remember in our Parse dashboard. So, in the Back4App dashboard, we already have seen those. So, this resides under server settings. For any reason, if you close this down you can reach it from here under core settings, you can come over here to get your App Id, okay? Copy it and come over here and paste it. Come over here to find your Client Key. So, this one. Come to here and paste it, and for last but not least we're going to need this server URL. So, this is our server URL, parseapi.back4app.com. So, I'll copy this and we don't need anything else at this point. So, I'm going to just paste it here and now we are done. So, I'm going to save this, and I'm going to run this. If we don't get any error it means that we managed to connect our app to our server. Of course, we have to do some further tests like writing some values to our database. We're not going to do that in this lecture but we're going to do that in the next lecture. For right now, I'm just trying to build what we have in here and see if we get any error. So, let me open this in my simulator and let's see if we get any errors or any unusual logs. So, did we close down the other app? Yap, we have closed down, so I believe that's good. Actually we can just delete this because we won't need it. So, here we go. Right now, I don't have anything in my storyboard but I don't get any errors as well. So, I believe we are good to go. Right now, we have completed this section so I'm going to close everything down. I don't even need this. All I need is my Back4App dashboard so that I can keep track of what's going on in my database. So, we're going to see how to write and read from database before we go on and create our first clear clone because we're going to use those operations a lot during our section. So, let's stop here and do that within the next lecture.

 

About the Author
Students
198
Courses
55
Learning Paths
3

Atil is an instructor at Bogazici University, where he graduated back in 2010. He is also co-founder of Academy Club, which provides training, and Pera Games, which operates in the mobile gaming industry.

Covered Topics