Break New Ground

Mobile Cloud Service the iOS way

Mobile, the new hip technology already replacing the legacy
computing devices. We see that in some emerging countries that Mobile is the
only device used to access the internet, which makes it a valuable platform to harness.

In this
article I would like to take a look at the native capabilities within the
Oracle Mobile Cloud Service especially iOS. Just to clarify this topic there are
multiple development options for using the MCS

Mobile Application Framework

Android SDK for native Android Development

iOS SDK [Objective C] for native iOS Development

Xamarin Studio for .net developers

If the Oracle Mobile Cloud Service is something new for you I suggest reading the intro session from our blog.

iOS with Objective C

At the time of this article the recommendations are to use xCode v6.x to write an iOS 8.x application using Objective C.

When accessing the Mobile Cloud Service (try it here!)  the first time you will encounter the Getting Started page.

MCS Dashboard.jpg

There you can choose the development platform that you prefer (Android/iOS). If you have an existing iOS project you can download the SDK and afterwards integrate it with your project. For this tutorial and the introductory process we will download the sample application that has already the MCS SDK integrated. Click the Get Started button.

MCS Platform choose.jpg

Click the iOS download icon - when opening your GettingStartediOS project in xCode you will observe the file structure and the imported libraries that are used for the MCS.

  • libOMCAnalytics.a    
  • libOMCCore.a
  • libOMCNotifications.a
  • libOMCStorage.a
  • libOMCSynchronization.a

The Project is split in the usual iOS development structure MVC.

  • The Appdelegate is the entrypoint of the app
  • LoginViewController - handles login functions
  • MainViewController - encapsulates all
  • UploadViewController - handles upload functions
  • DownloadViewController - handles download functions

When you first run the application you will be prompted with the splash screen. The application will not work out of the box, you need to make some configuration changes that will point to your particular instance of MCS. Do not worry the changes are simple to set up.

First you need to open up the OMC.plist from the Supporting Files folder and fill in all the informations received from the MCS Backend Settings Page. In this tutorial we are assuming that a Backend and Application id are created prior to editing the sample application.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">





























Second you will need to go into AppDelegate.m and replace the OMC_MBE_Name with your actual backend name and version like this:


The last step of the configuration requires the user to generate a Storage collection with at least on uploaded file. Go to the developer tab -> mobile backend, in the MCS account ?, (search for desired backend) -> storage and create a new collection with an item uploaded to it in order for you to gather the item ID.

Storage Collection.jpg

After the storage setup is done, open up the DownloadViewController.m file and update the following fields:

NSString* collection_Id = @"YOUR_STORAGE_COLLECTION_NAME";

NSString* object_Id = @"YOUR_STORAGE_ITEM_ID";

This would conclude the initial setup of the sample application. After this you should be able to login and perform a basic authentication.

After you login you can see the uploaded image.


From this point on I will start talking about MCS Analytics and how you could integrate this with your application.

Let us assume this use case, you have an application and you wish to place some custom analytics events in order for you to track the user's behaviour and generate a data heatmap of your app. To create custom analytics events we will have to write a little bit of code and discuss about the Analytics API. The OMCAnalytics class contains methods for logging events, posting all events to the server and starting and ending sessions.

(void) startSession // Starts an OMC Analytics session

(void) endSession // Stops the current OMC Analytics session and uploads all buffered events to MCS

Note that if you call the logEvent method it will start automatically a session if none exists. All information is stored locally in a JSON file until the app calls the flush or endSession methods.

Under the LoginViewController.m file you will observe that there you have defined a logAnalyticsEvent method that handles analytics events:

- (void) logAnalyticsEvent:(NSString *) message{

// Get analytics object

OMCAnalytics* analytics = [[appDelegate myMobileBackend]  analytics];

// Starting analytics session

[analytics startSession];

// Log analytics event

[analytics logEvent:message];


You will observe that the here we define the analytics component and then call the startSession and logEvent however this could be declared at the start of the application and we could call the logEvent method on specific actions like a push of button.

One particular feature that will come very handy to a developer is that you can add properties to your log events like this:

[analytics logEvent:@”Work order on Hold” properties:@{@”Reason”: @”Parts ordered”}]

Using this solution you can add specific information to your log events and therefore track the activity with high accuracy. These informations like “Reason” will be displayed in the Analytics tab on MCS as a subset to any logEvent type.

Analytics Capture.PNG

Another way to pass in information would be to include them all into a dictionary object like this:

// Creating Dictionary to store log event data

NSDictionary *properties = @{

@"Parts Location": @"On Truck",

@"Drive Time": @"Less than 5 min",

@"On Site Time": @"More than 30 min"


// Log the Specific information

[analytics logEvent:@"Work Order On Hold" properties:properties];

I hope you enjoyed this introductory session on using MCS with the iOS SDK. Stay tuned for more mobile articles.

For more information:


Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.

Recent Content