I recently got the opportunity to play around with the awesome Parse Platform. Parse offers a cloud backend service for mobile apps. This lets developers focus on on creating an awesome app and user experience without having to worry about managing server maintenance or infrastructure.
In this post I am going to highlight some key points with Parse and iOS that will let you create a grocery list app that emails you the list. We will take advantage of the Parse platform’s SendGrid Module as well as its PFQueryTableViewController which has a ton of cool features baked in. This tutorial assumes you have some knowledge of xCode and have created apps before. Feel free to download the full source on GitHub to see how this app was created.
Setting up XCode, Parse and SendGrid
- Make sure you have an account setup for both Parse and SendGrid. They each have free versions.
- Open up xCode and create a new application. Make sure to choose Single View Application.
- Give your project a name. For the purpose of this tutorial I’ve named the app GroceryList.
- Now log into Parse and access your dashboard to create a new app.
- Let’s name this app GroceryList
- Click on the Quickstart guide orange button. Follow the directions
Create Classes and Controllers
- Next, create a new Parse class for storing our Grocery List items. We do this by going to the Parse Dashboard and clicking on your app, in this tutorial it is the GroceryList app. Once there click on the Data Browser Screen and then the New Class Button.
- Create a new column called “item” and classify it as a String. We will be storing the name of our grocery items in this field.
- Go back to xCode and drag and drop a new Table View Controller from the object bar on the bottom right of xCode into your Storyboard.
- Create a new class for the Table View Controller and paste this code for the Controller.h and Controller.m files of the class. This will use Parse as the data source for your Table View and also have cool functionality such as swiping the screen down to refresh the table.Note on adding data: This tutorial does not include the app screens for adding items to the list, but the full source does. For testing, you can add items via the Parse class page.
Connect to Cloud Email
- Now we get to the fun part. Emailing this list to ourselves using Parse Cloud Modules. To begin follow the instructions for getting started with the cloud modules.
- Once you have finished modify your main.js file to look like the following:
Then in your terminal, type “Parse deploy”
- Now whenever someone clicks on the sendList button in our app, all we need to do is include these lines to call our cloud module:
This code is sending the NSString List that we built up in our ViewController.m file to our email using the SendGrid API.
Video: Grocery List App in Action
While this application is a grocery app, it can easily be modified to become any sort of list making application. Get started by downloading the full source on GitHub.