Before You Begin
This tutorial will show you how to develop an iOS app using Oracle Mobile Cloud Service (MCS). You should be able to complete it in about 30 minutes.
Background
MCS is a cloud service that provides a unified hub for developing, deploying, maintaining, monitoring, and analyzing your mobile apps and the resources that they rely on.
What Do You Need?
- A desktop or laptop computer running MacOS.
- Xcode
- Access to an MCS instance
- The iOS Get Started project from the Oracle Mobile Cloud Service Client SDK Downloads page
Create Mobile Backend
A mobile backend is the server-side companion to your mobile application. It provides secure access to services like storage, notifications, user management, and custom APIs.
To create a mobile backend do the following:
- Log in to your MCS instance, click and select Mobile Backends.
- Click the New Mobile Backend button.
- Enter
MCS_QL_Test
and click Create. - Select Settings and copy the following to a handy place on your system. We'll use this information later in this tutorial.
- Mobile Backend ID
- Anonymous Key
- Base URL
Keep your backend open because you will be using it in the next steps.
Create Storage Collection
Now you'll create a storage collection in MCS and add an image to it. This collection will serve as container for your mobile application.
- In the left navigation bar of the mobile backend, click Storage.
- Click New Collection.
- Create a collection called Customer_Images.
- In the New Collection dialog, select Shared.
- Click Create
-
In the Read-Only field, type
FIF_Technician
.This ensures that only users with that role have access to that collection, including the user you've set up in the previous part.
- Select the Content tab.
-
Click Upload Files and use the file chooser to select a file to upload, preferably an image.
After the object is loaded, you'll see it listed on the page.
- Copy the ID of that object and paste it somewhere handy. You'll need it a bit later.
- Click Mobile Backends and open the MCS_QL_Test backend you created in the Create Mobile Backend part.
- Click Storage from the Mobile Backend left menu and then click Select Collections.
- Type in the Collections field
Customer_Images
and then click Select to associate this collection with your Mobile Backend.
Create a Test User
In this part you create a test user to test the running application.
If you did not leave your mobile backend open in a new tab, go to the mobile backend by doing the following in MCS: Click the side menu, Select Applications, Mobile Backends, then select your mobile backend, and click Open.
- In the left navbar of your mobile backend, click Mobile User Management.
- Click Users and then click New User.
- Enter
bob
as Username. - Enter a valid Email address. Your temporary password will be sent to the email address you enter.
- Enter
Bob
as First Name andJones
as Last Name. - Select the FIF_Technician role from the Roles box by clicking on the Roles text box.
- Click Create.
Configure the App
In this section, we'll set up your application to work with MCS.
Use the user name and password you created in the Get Test User step.
MCS allows you to use either OAuth
or BasicAuth
for authentication. For this lab, we use BasicAuth
.
Note: The credentials differ by environment. An environment is a runtime container that holds your mobile backends, APIs, and other artifacts. You typically start work in a development environment, and eventually deploy your artifacts to a staging or production environment.
- Unpack the iOS Get Started project zip.
- Add the project to Xcode.
- Open
GettingStartediOS/GettingStartediOS/Supporting Files/OMC.plist
and replace the following items - In the project, open
main/assets/oracle_mobile_cloud_config.xml
and- Replace
MyBackend
with theMCS_QL_Test
. - Replace the String values for the following keys with the values you copied from the mobile backend's Settings page:
- Your_Mobile_Backend_Name.
- baseURL
- mobileBackendID
- anonymousKey
- Replace
- Open
GettingStartediOS/GettingStartediOS/AppDelegate.m
and navigate to the statement:#define OMC_MBE_Name @"YOUR_MBE_NAME"
- Replace
YOUR_MBE_NAME
withMCS_QL_Test
. - Open
GettingStartediOS/GettingStartediOS/DownloadViewController.m
and navigate to the declarations for thecollection_Id
andobject_Id
variables. - For those variables:
- Assign
Customer_Images
as the value forcollection_Id
. - Assign the ID for the object that you uploaded in section 2 to
object_Id
.
- Assign
- If you are using Xcode 7 or higher, you need to account for the Application Transport Security (ATS) policy, which enforces remote communications to be over HTTPS.
For development purposes only, add the following key in app's Info.plist file to turn off the ATS policy for the app:
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
Note: You shouldn't use this setting in production. To make sure you provide optimal security for your app, study Apple's documentation for NSAppTransportSecurity and follow Apple's recommendations for disabling ATS for specific domains and applying proper security reductions for those domains.
Run the App
- In Xcode, run the target for the app.
Xcode will build the application and then launch it in the simulator or device of your choice.
- In the running app, click Sign In, and enter your test user's user name and password.
- Click Download Image.
The image you previously added to the storage collection should display in the emulator.
You've made contact!
Keep the project on your system. It will come in handy for the other getting started tutorials.
Want to Learn More?
- See Getting Started to learn more about MCS.
- See this end-to end tutorial to learn more about MCS.
- See the user guide to get more details on working with the features that you want to explore first.
- See Configuring the MCS SDK on iOS for a video walkthrough of connecting an Android app to MCS.