Oracle by Example brandingDevelop an iOS Mobile Application using Oracle Mobile Cloud Service

section 0Before 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?

section 1Create 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:

  1. Log in to your MCS instance, click the main menu and select Mobile Backends.
  2. Click the New Mobile Backend button.
  3. Enter MCS_QL_Test and click Create.
  4. 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.


section 2Create 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.

  1. In the left navigation bar of the mobile backend, click Storage.
  2. Click New Collection.
  3. Create a collection called Customer_Images.
  4. In the New Collection dialog, select Shared.
  5. Click Create
  6. 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.

  7. Select the Content tab.
  8. 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.

  9. Copy the ID of that object and paste it somewhere handy. You'll need it a bit later.
  10. Click Mobile Backends and open the MCS_QL_Test backend you created in the Create Mobile Backend part.
  11. Click Storage from the Mobile Backend left menu and then click Select Collections.
  12. Type in the Collections field Customer_Images and then click Select to associate this collection with your Mobile Backend.

section 3Create 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.

  1. In the left navbar of your mobile backend, click Mobile User Management.
  2. Click Users and then click New User.
  3. Enter bob as Username.
  4. Enter a valid Email address. Your temporary password will be sent to the email address you enter.
  5. Enter Bob as First Name and Jones as Last Name.
  6. Select the FIF_Technician role from the Roles box by clicking on the Roles text box.
  7. Click Create.

section 4Configure 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.

  1. Unpack the iOS Get Started project zip.
  2. Add the project to Xcode.
  3. Open GettingStartediOS/GettingStartediOS/Supporting Files/OMC.plist and replace the following items
  4. In the project, open main/assets/oracle_mobile_cloud_config.xml and
    • Replace MyBackend with the MCS_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
  5. Open GettingStartediOS/GettingStartediOS/AppDelegate.m and navigate to the statement:
    #define OMC_MBE_Name @"YOUR_MBE_NAME"
  6. Replace YOUR_MBE_NAME with MCS_QL_Test.
  7. Open GettingStartediOS/GettingStartediOS/DownloadViewController.m and navigate to the declarations for the collection_Id and object_Id variables.
  8. For those variables:
    • Assign Customer_Images as the value for collection_Id.
    • Assign the ID for the object that you uploaded in section 2 to object_Id.
  9. 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.


section 5Run the App

  1. 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.

  2. In the running app, click Sign In, and enter your test user's user name and password.
  3. 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.


more informationWant to Learn More?