How To Choose the Best Backend Provider for your iOS App: Parse vs Stackmob vs. Appcelerator Cloud and More!
This is a post by Tutorial Team Member Antonio Martínez, a mobile software developer currently working as an iOS Developer in London. It’s quite common for apps to require a web backend. This allows you to have a central database where users can share content with each other, like photos, messages, or restaurant reviews. In […] By .
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
How To Choose the Best Backend Provider for your iOS App: Parse vs Stackmob vs. Appcelerator Cloud and More!
35 mins
Parse: Persistent Points
Features, Pricing, and Documentation
Parse stands out for being one of the the easiest and fastest backend services to work with, as well as having the best documentation. The documentation is easy to understand, as well as being comprehensive. Generally, it will take you less time to start uploading objects to Parse than any other service.
Parse offers most of the features that you’d expect from a backend service provider, including the following:
- Custom Objects
- Users
- Push Notifications
- Social Integration
- Files
- Geolocation
The pricing of the tiers in Parse is again based on API calls, and has a much bigger jump to the paid tier than does StackMob:
- Free: 1M API Calls, 1M Push notifications (0.07 per 1k over)
- $199: 15M API Calls, 15M Push notifications (0.05 per 1k over)
Code Examples
The following code sample shows you how to upload a new object in Parse, again using the mythical Player application:
PFObject *player = [PFObject objectWithClassName:@"Player"];
[player setObject:@"Player1" forKey:@"Name"];
[player setObject:[NSNumber numberWithInt:1000] forKey:@"Score"];
[player saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (succeeded){
NSLog(@"Object Uploaded!");
}
else{
NSString *errorString = [[error userInfo] objectForKey:@"error"];
NSLog(@"Error: %@", errorString);
}
}];
Relatively simple, and along the same lines as StackMob. With Parse, the process of uploading the object to the server can be done in synchronous mode or asynchronous using a block or a selector.
The code to retrieve an object in Parse is again incredibly straightforward, and in half the lines of code that StackMob requires:
PFQuery *query = [PFQuery queryWithClassName:@"Player"];
[query whereKey:@"Score" greaterThan:[NSNumber numberWithInt:900]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
NSLog(@"Successfully retrieved: %@", objects);
} else {
NSString *errorString = [[error userInfo] objectForKey:@"error"];
NSLog(@"Error: %@", errorString);
}
}];
Deleting an object in Parse is again a very simple operation:
PFObject *player = [PFObject objectWithClassName:@"Player"];
[player setObject:@"Player1" forKey:@"Name"];
[player deleteInBackgroundWithBlock:^(BOOL succeeded, NSError *error){
if (!error) {
NSLog(@"Successfully deleted");
} else {
NSString *errorString = [[error userInfo] objectForKey:@"error"];
NSLog(@"Error: %@", errorString);
}
}];
This is how the web interface for the Parse object browser looks after uploading an object:
Running the Sample Project
I’m not going to include instructions on how to set up Parse here, since I am going to release a step-by-step tutorial on how to build this project from scratch in a few days!
So stay tuned for our upcoming tutorial. In the meantime, you can get a sneak peek by downloading the completed project from github.
Appcelerator: Accelerating App Access
Features, Pricing, and Documentation
Appcelerator Cloud Services stands out for being the most comprehensive backend service provider of all. Appcelerator Cloud is geared towards developers using the Titanium SDK, so your experience may vary if you are not using Titanium. However, a quick read through the documentation and main concepts of Appcelerator Cloud will get you up and running quickly.
Appcelerator Cloud Services are a bit different in that they break the various features into two tiers. The two-tiered model bundles most of the common features into the first tier, and puts more of the value-added services into the second tier, as shown:
Tier 1:
- Users
- Photos
- Custom Objects
- Push notifications
- Email Templates
Tier 2:
- Places
- Status
- Posts
- Clients
- Social Integration
- Check-ins
- Chat
- Photo Collections
- Ratings, Reviews & Likes
As you can see, there is a more comprehensive range of predefined functionality with Appcelerator Cloud Services.
Pricing for the various services with Appcelerator is as follows:
- Free: 250k Tier 1 API Calls, 250k Tier 2 API Calls
- Paid: Pricing for the Standard, Enhanced, and Premium paid tiers is not made public on the Appcelerator web site; before committing to using ACS in your app, you should contact the sales team and be sure of what your ongoing costs will be!
Code Examples
Uploading an object in Appcelerator Cloud Services is again very easy and comparable to Parse and StackMob. You’re still working with our hypothetical Players app here:
NSMutableDictionary *fieldsDict = [NSMutableDictionary dictionaryWithCapacity:2];
[fieldsDict setObject:@"Player1" forKey:@"name"];
[fieldsDict setObject:[NSNumber numberWithInt:1000] forKey:@"score"];
NSDictionary *paramDict = [NSDictionary dictionaryWithObject:fieldsDict forKey:@"fields"];
CCRequest *request = [[[CCRequest alloc] initWithDelegate:self httpMethod:@"POST"
baseUrl:@"objects/playerscore/create.json" paramDict:paramDict] autorelease];
[request startAsynchronous];
Retrieving objects in Appcelerator is again extremely straightforward:
CCWhere *where = [[[CCWhere alloc] init] autorelease];
[where fieldName:@"score" greaterThan:[NSNumber numberWithInt:900]];
NSMutableDictionary *paramDict = [NSDictionary dictionaryWithObjectsAndKeys:where,@"where", nil];
CCRequest *request = [[CCRequest alloc] initWithDelegate:self httpMethod:@"GET"
baseUrl:@"objects/playerscore/query.json" paramDict:paramDict];
[request startAsynchronous];
Deleting objects in Appcelerator is, once again, a simple operation:
NSDictionary *paramDict = [NSDictionary dictionaryWithObject:@"5049c26fb685537c3902c711"
forKey:@"id"];
CCRequest *request = [[[CCRequest alloc] initHttpsWithDelegate:self httpMethod:@"DELETE"
baseUrl:@"objects/playerscore/delete.json" paramDict:paramDict] autorelease];
[request startAsynchronous];
To check the response from the server for any of these calls you must use a delegate; this should be a very familiar pattern to any iOS developer, as blocks are becoming more commonly used for network operations. A single delegate function is used for all of the create, retrieve, and delete operations:
-(void)ccrequest:(CCRequest *)request didSucceed:(CCResponse *)response
{
if ([response.meta.methodName isEqualToString:@"createObject"]){
NSLog(@"Object created");
}
if ([response.meta.methodName isEqualToString:@"queryCustomObjects"]){
NSLog(@"%@", [response.response objectForKey:@"playerscore"]);
}
if ([response.meta.methodName isEqualToString:@"deleteObjects"]){
NSLog(@"Deleted");
}
}
Unlike Parse and Stackmob, in Appcelerator you must be the owner of an object in order to modify or delete it. To delete an object, you must provide the object’s unique ID, which can be discovered with an API call.
In contrast, in Stackmob and Parse you can simply provide enough information to identify the objects you want to perform operations on without first having to make an API call to retrieve the unique ID.
This is how the web interface for the Appcelerator object browser looks after uploading an object:
Running the Sample Project
Once again the sample project for working with Appcelerator is complete, but it is not configured with your project credentials.
Create your developer account with Appcelerator by signing up here. Once again, you don’t need to download the SDK for appcelerator, since it is included with the sample project.
Once you have created your account, go to Create New App in Appcelerator and create a new app called “tutorialacs”.
The final step is to add your App Key to the AppDelegate. You can find your Appcelerator App Key by navigating to the “Manage ACS” screen once your app has been created.
Update the code below with the App Key you retrieved from Appcelerator:
//Put your key here
#define COCOAFISH_APP_KEY @"1234-5678"
And you’re done! Just like the sample application that was provided that leveraged the StackMob service, now you can upload and view images and comments in your app.