Cortex iOS
Cortex iOS SDK
About the Medable SDK
Welcome to the iOS Client SDK for Medable. This framework provides a wrapper for the Medable API as well as several helper tools to directly integrate those features to your iOS application.
Installation
Using CocoaPods
Step 1: Download CocoaPods
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like Medable in your projects.
CocoaPods is distributed as a ruby gem, and is installed by running the following commands in your Terminal:
$ sudo gem install cocoapods
$ pod setup
Depending on your Ruby installation, you may have to run as
sudo
to install the CocoaPods gem.
Step 2: Create a Podfile
Project dependencies to be managed by CocoaPods are specified in a file called Podfile
. Create this file in the same directory as your Xcode project (.xcodeproj
) file.
Copy and paste the following lines into the file:
target 'yourTargetName' do
platform :ios, '7.0'
pod 'Medable'
end
Step 3: Install Dependencies
Now you can install the dependencies in your project:
$ pod install
From now on, be sure to always open the generated Xcode workspace (.xcworkspace
) instead of the project file when building your project:
$ open <YourProjectName>.xcworkspace
That's it, you are now ready to use the Medable SDK. Skip over to the Integration section below to continue your setup.
Manual Installation
Follow the Manual Installation Guide for instructions on how to install the Medable iOS SDK manually.
Swift
The Medable SDK is written in Objective-C but using it from your Swift application is straightforward. Just add a bridging header to your app target:
//
// MedableSwift-Bridging-Header.h
// MedableSwift
//
// Copyright (c) 2015 Medable Inc. All rights reserved.
//
#import <Medable/Medable.h>
Make sure your Build Settings for the app target specify the bridging header (the entry is called Objective-C Bridging Header
):
//:configuration = Debug
SWIFT_OBJC_BRIDGING_HEADER = MedableSwift/MedableSwift-Bridging-Header.h
//:configuration = Release
SWIFT_OBJC_BRIDGING_HEADER = MedableSwift/MedableSwift-Bridging-Header.h
Finally, after initializing, you can use Medable classes directly:
let client = Medable.client()
See Swift and Objective-C in the Same Project in Apple's developer documentation for more information
Integration
Configuring the Client
You need to provide a Medable Client Key and your Organization name to the SDK. The simplest way to do this is to add an entry to your app's plist
file with this information.
A sample BaseURL
: api.medable.com
.
The next figure shows how this would look when viewing the main .plist
file:

For advanced integration steps, follow the Advanced Integration Guide .
NoteIf, for some reason, you need to provide the organization and clientKey programmatically read below in the Optional Integration Steps section.
Initialization
For initializing Cortex iOS, just place this in your app delegate or as soon as you can in your app's flow:
[Medable start];
Medable.start()
If you need to provide the organization and clientKey programmatically, initialize the Medable SDK this way instead:
[Medable setOrganization:@"your org name" clientKey:@"your client key"];
[Medable start];
Medable.setOrganization("your org name", clientKey: "your client key")
Medable.start()
Set log level
// Change log level
[Medable client].loggerLevel = MDAPIClientNetworkLoggerLevelDebug;
// If not set, the default loggerLevel is MDAPIClientNetworkLoggerLevelInfo.
// Change log level
Medable.client().loggerLevel = MDAPIClientNetworkLoggerLevelDebug
// If not set, the default loggerLevel is MDAPIClientNetworkLoggerLevelInfo.
Handling particular events by listening to notifications.
kMDNotificationAPIServerErrorDidOccur: This notification comes with the corresponding MDFault object, ready to be handled. Fault codes are listed in MDConstants.h.
kMDNotificationUserDidLogout: This notification is used to forward the app to the login screen. This notification is thrown when the user logs out, or when API session is over because of an error or session timeout.
Note: More notifications are defined in MDConstants.h.
Getting Started
You can access the Medable Cortex iOS SDK API at Cocoadocs. The main API class is MDAPIClient
which you can access by getting the shared client using this line:
MDAPIClient *medable = [Medable client];
let medable = Medable.client()
From there, check the SDK API, the examples or tutorials to accomplish specific things.
Examples
Check out the Code Samples for a few examples on how to get some specific things done with the Medable SDK.
Updated 4 months ago