Configure the Oracle Mobile Hub SDK with your Mobile Application
You must configure the Oracle Mobile Hub SDK with your mobile application before you write any code.
Add the SDK
In a basic app setup, without intervening frameworks, you'll add the iOS client SDK to an app.
-
Unzip the download file,
omce-ios-sdk-{n}.zip
(where {n} is the version number of the SDK) into some directory on your machine. -
From the extracted contents of the zip, drag and drop the
oracle_mobile_ios_sdk
directory to the Xcode project navigator.-
Select Copy items if needed.
-
Select Create Groups.
-
Click Finish.
Once the
.a
file for a specific library has been copied into your application’s development tree in Xcode, the corresponding platform API is available to your app through SDK calls. At this point, all of the SDK’s static libraries are available to your app. -
-
Select the target for your project, select the Build Phases tab, expand Link Binary with Libraries, click the + button, and add the following libraries:
-
CoreData.framework
-
CoreLocation.framework
-
libsqlite3.0.tbd
-
Security.framework
-
SystemConfiguration.framework
-
-
In the Build Settings section for the project, double-click Other Linker Flags (under Linking) and add
-ObjC
. -
Also in Build Settings, expand Search Paths and:
-
Add
oracle_mobile_ios_sdk/release-iphoneos
to Library Search Paths. -
Add
oracle_mobile_ios_sdk/release-iphoneos/include
to User Header Search Paths.
-
-
Expand the
Documentation
folder of the unpacked zip, copy theOMC.plist
file, and place it in the root of your app’s main application bundle. -
Edit the just-copied
OMC.plist
file. -
Starting with Xcode 7, 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 and follow Apple's recommendations for disabling ATS for specific domains and applying proper security reductions for those domains.
Configure SDK Properties
To use the client SDK in an iOS app, you need to add the OMC.plist
configuration file to the app and fill it in with environment details for your backend
in Oracle Mobile Hub, as well as other configuration information. In turn, the SDK classes use this information
to help manage authorization, logging, event tracking, data synchronization, and other
features.
You package the configuration file in the root of your app’s main bundle.
The file is essentially divided into the following parts:
-
The
mobileBackend
key and its contents.You include this part if you are using a backend with the app. The SDK classes use the environment and authentication details you specify there to access the backend and construct HTTP headers for REST calls made to APIs.
-
Keys that apply to the configuration as a whole, such as
logLevel
andoAuthTokenEndpoint
. These keys generally, but don’t have to, appear at the top of the file.
Here’s the same file in text form:
<?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">
<dict>
<key>logLevel</key>
<string>debug</string>
<key>logHTTP</key>
<true/>
<key>oAuthTokenEndPoint</key>
<string>https://MY_TOKEN_ENDPOINT</string>
<key>mobileBackend</key>
<dict>
<key>name</key>
<string>EasyShoppingMBE</string>
<key>baseURL</key>
<string>https://MY_CLOUD_DOMAIN.oracle.com</string>
<key>authentication</key>
<dict>
<key>type</key>
<string>oauth</string>
<key>oauth</key>
<dict>
<key>clientID</key>
<string>11dac238ffaa4b029e78e982114642ab</string>
<key>clientSecret</key>
<string>5624cbdd-a7c5-4c10-a758-6019a5ab8da8</string>
<key>enableOffline</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
And here is a description of some of the more important entries in the OMC.plist
file.
-
oAuthTokenEndPoint
— The URL of the OAuth server from where your application gets its authentication token. This key needs to be provided for all apps that rely on OAuth to authenticate. You get this from the backend’s Settings page. The endpoint should be only the base URL (in the formhttps://host.domain:port
). -
logLevel
— Determines how much SDK logging is displayed in the app’s console. The default value iserror
. Other possible values (in increasing level of detail) arewarning
,info
, anddebug
. It is also possible to set the value tonone
. -
logHTTP
— When set totrue
, the SDK logs the headers and bodies of all HTTP requests and responses. -
mobileBackend
— A dictionary entry containing authentication details for your backend and other optional details, such as synchronization properties.You get the authentication details, such as the OAuth and HTTP credentials, from the backend’s Settings page.
-
mobileBackend/baseUrl
— The base URL for all APIs that you call through the backend. You get this from the backend’s Settings page. -
mobileBackend/authentication
— Contains a dictionary with the following elements:-
The
type
sub-key, with possible (string
) values ofoauth
,basic
,facebook
, andtokenExchange
. -
One or more sub-keys for authentication types, containing a dictionary with the authentication credentials.
Within sub-keys for
basic
andoauth
, you can also add theenableOffline
key. By default, this property is set totrue
.
-