Skip to content

Parse Server with Back4App Quick Start

charlie-codepath edited this page Oct 31, 2022 · 11 revisions

Overview

A quick start guide to setting up a Parse server hosted on Back4App

Sign up

  1. Go to Back4App and choose a "Sign up" option. The following example shows the "Sign up with GitHub" flow. Make sure you're signed in to GitHub with the account you want to use with Back4App. 1_b4a_sign_up_github
  2. Authorize with GitHub
    2_b4a_authorize_github
  3. "Skip" or "Continue" through the "Welcome" flow.
    3_b4a_welcome_flow
  4. Name your server app.
    4_b4a_app_name

Dashboard

  • "Cancel" or "Next" at "Onboarding" flow for a brief dashboard orientation. 6_b4a_onboard_help

Database

  • There isn't any data to see yet, but this is where all your Parse user's and objects will be displayed. 7_b4a_database_initial_empty

App Settings

General

  • This is where general info about your app is displayed.
  • You'll reference the "Parse API Address" when configuring the Parse SDK in your Xcode project. 8_b4a_app_settings_general_api_address

Security & Keys

  • You'll reference the "Application ID" and "Client Key" when configuring the Parse SDK in your Xcode project. 9_b4a_app_settings_security_keys

Configure and initialize the Parse SDK in Xcode

  1. Visit the Parse iOS Docs - Getting Started Tab and scroll down to the section titled "Initialise Parse SDK"

  2. In the code snippet, tap the "Swift" button to toggle the snippet to show in Swift.

  3. As the description mentions, you'll need to configure the Parse SDK in the application:didFinishLaunchingWithOptions: method of your app's AppDelegate.swift file. (This is a common place for initializing stuff in your app since this method is called very early in the app's lifecycle, right after your app initializes itself).

    • ⚠️ Make sure you import Parse in any file you want to use Parse. In this case, at the top of the AppDelegate.
    • ⚠️ The snippet shown in the Parse docs also includes the application:didFinishLaunchingWithOptions: method, however that method is already provided by default in the app delegate. So you only need to reference the part related to the configuration and initialization of Parse. Add that inside the application:didFinishLaunchingWithOptions: that already exists in the AppDelegate.
    let parseConfig = ParseClientConfiguration {
        $0.applicationId = "parseAppId"
        $0.clientKey = "parseClientKey"
        $0.server = "parseServerUrlString"
    }
    Parse.initialize(with: parseConfig)
    • You'll need to replace the parseAppId, parseClientKey and parseServerUrlString strings with the actual values from your Parse server found in the Dashboard - App Settings

Test and confirm your server and app setup

  1. To test if your app is able to communicate with your Parse server, try creating and saving a parse object in your app, and verifying that the object appears in the Dashboard on your Parse server.
  2. Visit the Parse iOS Docs - Saving Objects tab, and check out the example snippet for saving a Parse Object (aka PFObject).
  3. As the docs mention, creating and setting keys and values on a PFObject is quite similar to working with a Swift Dictionary.
  4. Add the save object snippet right after you initialize the Parse SDK in order to test it.
    • Feel free to switch up any of the keys and values to help prove to yourself that things are really working as expected. It's also helpful to add print statements in the case of success or errors.
    let gameScore = PFObject(className:"GameScore")
    gameScore["score"] = 5000
    gameScore["playerName"] = "Kingsley 🐶"
    gameScore["cheatMode"] = true
    gameScore.saveInBackground { success, error in
        if success {
            print("👩‍🔬✅ SUCCESS! Parse object saved")
        } else if let error = error {
            print("👩‍🔬❌ Error saving Parse object: \(error.localizedDescription)")
        } else {
            print("👩‍🔬❌ Unknown error saving Parse object")
        }
    }
    
  5. Run your app check the Xcode console to see if the save was a success.
  6. For the final proof, head to your Parse Server Dashboard and verify that your PFObject was successfully saved in the Database section. test_parse_setup

Success! Your server and app are setup and ready to go! 🚀

Clone this wiki locally