Now that you have created an App at Back4App, the next step to use the backend features is to connect with Back4App servers. You will see how to install the SDK and initialize your App project using the Back4App API and your Keys.
The Open source Parse SDK is available in the main frontend technologies including JavaScript (ReactJS, React Native, AngularJS, VueJS, NodeJS), iOS (Objective-C/Swift), Android (Java/Kotlin), Flutter, PHP, .NET/Xamarin, Unity, Embedded C. You can also connect using the GraphQL or REST APIs.
In this guide, you will connect and send your first API Call to Back4App using the Parse SDK.
Goal
To Add Back4App to your software project using the Parse SDK.
Prerequisites
To complete this tutorial, you will need:
An application software project environment ready to use.
Find your application keys at Core Settings. go to Server Settings > Core Settings > Settings > App Id and other.
Parse SDK for JavaScript can be used in a large amount of platforms and frameworks. To deal with it, the Parse npm module contains many versions to use in different environments. Below, you can choose 4 possibilities to install the Parse JS SDK:
1. Install the NPM module
Install the Parse NPM module and the AsyncStorage. To do so, run the following command.
Use CocoaPods to add the native RNAsyncStorage to your project:
cd ios & pod-install
2. Install the SDK
App.js
11import AsyncStorage from'@react-native-async-storage/async-storage';22import Parse from'parse/react-native';3344//Before using the SDK...55 Parse.setAsyncStorage(AsyncStorage);
We strongly encourage you to use the latest Parse NPM module. To do so, run the following command.
$ npm install parse --save
2. Install the SDK
Node.js
11var Parse =require('parse/node');2233 Parse.initialize("APP_ID","JS_KEY");//PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY44 Parse.serverURL ='https://parseapi.back4app.com/'
We strongly encourage you to use the latest Parse NPM module. To do so, run the following command.
$ npm install parse --save
2. Install the SDK
JS
11import*as Parse from'parse';2233 @Component({...})4455exportclassAppComponent{66...7788constructor(){99// Initialize your Parse App Keys1010 Parse.initialize("APP_ID","JS_KEY");//PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY1111 Parse.serverURL ='https://parseapi.back4app.com/'1212}1313}
After creating your index.html, install Parse SDK directly on it, inside the <head> tag, using the code below.
HTML
11 <!DOCTYPEhtml>22 <html>33 <head>44 <title>My First Application</title>55 <scripttype="text/javascript"src="https://npmcdn.com/parse/dist/parse.min.js"></script>66 <scripttype="text/javascript"type="text/javascript">77 Parse.initialize("APP_ID","JS_KEY");//PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY88 Parse.serverURL ='https://parseapi.back4app.com/'99</script>1010 </head>1111 <body>1212 <!--
1313 Your code
1414 -->1515 </body>1616 </html>
Go to your Android Studio Project and find the build.gradle (Module:app) file. After that, copy and paste the code snippet right after thedependencies{} tag.
It’s also necessary to look in theandroid{} tag if the compileSdkVersion of your app is 27 or higher and also if the targetSdkVersion of your app is 27 or higher. If they aren’t, you must change these versions to 27 or higher, otherwise your Parse SDK for Android may not work properly.
Install the Parse Android SDK
To install the latest Parse Android SDK in your application, continue in the build.gradle(Module:app) file and copy and paste the code snippet inside the dependencies{} tag.
Java
11 android {...}2233 dependencies {44// code...55// Don't forget to change the line below with the latest version of Parse SDK for Android66 implementation "com.github.parse-community.Parse-SDK-Android:parse:latest.version.here"77}
You can find out which is the latest version of Parse SDK for Android at the Jitpack Website.
Xcode can use CocoaPods as a dependency manager for Swift and Objective-C Cocoa projects. To install CocoaPods, copy the following code snippet, paste it into your terminal, and hit return.
Open your project’s AppDelegate file to set up the app’s credentials. Parse SDK for iOS uses these settings to connect to the Back4App servers. At the top of the file, you should see a function called didFinishLaunchingWithOptions. Paste the following code snippet inside this function, and make sure it is above the line that says return true.
iOS Swift
At the top of your AppDelegate.swift file make sure to include Parse as a module by using the following code snippet right below import UIKit.
AppDelegate.swift
11 import Parse
iOS Objective-C
At the top of your AppDelegate.m file make sure to include Parse as a module by using the following code snippet right below #import "AppDelegate.h".
AppDelegate.m
11#import <Parse/Parse.h>
Facing any trouble? Feel free to check the complete Install Parse SDK guide for iOS Swift and iOS ObjC projects. Also, feel free to check the official Parse Documentation regarding Parse SDK for iOS.
PHP
You can use different ways to install the Parse SDK for PHP. We will show a couple of them here. Note that the Parse PHP SDK requires PHP 5.4 or newer.
With composer
Create a composer.json file in your project's root folder, containing the following.
{
"require": {
"parse/php-sdk" : "1.6.*"
}
}
Now, you need to run the “composer install” to download and set up the autoloader. After that, you can require it from your PHP script, using the code below.
PHP
11 require 'vendor/autoload.php';2
With Git
Go to Parse SDK for the PHP page on GitHub and clone it. You can do this by using your favorite GitHub client or via a terminal, as shown below.
After that, inside your PHP file, you need to include the autoload.php to automatically load the Parse SDK classes.
Facing any trouble? Feel free to check the official Parse Documentation regarding Parse SDK for PHP.
.NET
We need to add some libraries to set up Parse SDK for .NET. We will get them through Nuget Packages. To do so, go to Microsoft Visual Studio, and at the Solution Explorer, click on your app’s name and go to Manage NuGet Packages... .
Then, click on Browse to search and install the packages parsed by Parse and Xamarin.Android.Support.v7.AppCompat by Xamarin Inc.
Facing any trouble? Feel free to check the official Parse Documentation regarding Parse SDK for .NET.
Facing any trouble? Feel free to check the official Parse Documentation regarding Parse SDK for Unity.
3 - Insert your Keys and initialize Parse SDK
Please check the comments before copying and use the code below.
JS
Flutter
Android
Swift
ObjectiveC
PHP
Unity
1//To initialize Parse SDK in your JavaScript project, 2//add the code below in your index.html file, inside <script> tag.345Parse.initialize("APP_ID","JS_KEY");//PASTE HERE YOUR Back4App APPLICATION ID AND YOUR JavaScript KEY6Parse.serverURL ='https://parseapi.back4app.com/'
Your keys are available at your Dashboard >App Settings>Security & Keys.
Unity
You need to add your applicationId and dotNetKeyto your project. To do so, click on Back4appDemoSence, find a GameObject that calls Back4appIntialize, and paste there your keys, as shown in the image below.
Facing any trouble? Feel free to check the official Parse Documentation regarding Parse SDK for Unity.
4 - Save and Read your first Data Object
To ensure that the connection between your project and Back4App has been established correctly, let’s make a test in which we will save and read an object in Back4App.
Use the code according to the Parse SDK you are using.
JS
Flutter
Arduino
Swift
ObjectiveC
PHP
.NET
Unity
REST API
11//Saving your First Data Object on Back4App22 ParseObject person =newParseObject("Person");33 person["name"]="John Snow";44 person["age"]=27;55 await person.SaveAsync();6677//Reading your First Data Object from Back4App88 ParseQuery<ParseObject> person = ParseObject.GetQuery("Person");99 ParseObject query = await person.GetAsync("mhPFDlCahj");10101111// To get the values out of the ParseObject, use the Get<T> method.1212 string name = query.Get<string>("name");1313 int age = query.Get<int>("age");14
5 - Go to Dashboard and check your Data
After running the code chosen above, you can back to your Dashboard and refresh the browser to see the changes :)
What to do Next?
After a quick start, we recommend keeping exploring the Back4App main features by checking out the guides below.