We will add cloud-based backend service to an iOS app using Azure Mobile Services.
We need a Microsoft Azure Account.
Create new mobile service
Follow these steps to create a new mobile service.
1) Sign into http://manage.windowsazure.com. At bottom of navigation pane, click +NEW. Expand Compute and Mobile Service, then click Create.
This displays Create a Mobile Service dialog.
This displays Specify database settings page.
NOTE: We will create new SQL Database instance and server. We can reuse this new database and administer it as we would any other SQL Database instance. If we already have database in same region as new mobile service, we can instead choose Use existing Database and select that database. Use of a database in different region is not recommended because of additional bandwidth costs and higher latencies.
3) In Name, type name of the new database, then type Login name, which is administrator login name for new SQL Database server, type and confirm the password and click check button to complete process.
You have now created new mobile service that can be used by your mobile apps.
Create a new iOS app
We can follow an easy Quick Start in Azure classic portal to create new app connected to your mobile service:
1) In http://manage.windowsazure.com, click Mobile Services and then click mobile service that we just created.
2) In Quick Start tab, click iOS under Choose a platform and expand Create a new iOS app. This displays steps to create an iOS app connected to our mobile service.
3) Click Create TodoItem table to create table to store app data.
4) Under Download and run your app, click Download. This downloads project for sample To do list application that is connected to our mobile service, along with Mobile Services iOS SDK. Save compressed project file to our local computer and make a note of where we saved it.
Run your new iOS app
Final stage is to build and run our new app.
1) Browse to location where we saved compressed project files, expand files on our computer and open project file using Xcode.
2) Press Run button to build project and start app in iPhone emulator.
3) In app, type meaningful text and then click plus icon.
This sends POST request to new mobile service hosted in Azure. Data from request is inserted into TodoItem table. Items stored in table are returned by mobile service and data is displayed in list.
4) Back in the http://manage.windowsazure.com, click DATA tab and then click TodoItem table. This lets us browse data inserted by app into table.