Installing the Apigee SDK for iOS
Here's how to integrate Apigee functionality into your iOS application using the Apigee SDK for iOS.
The following are required for using the SDK for iOS:
Get an Apigee developer account
For more about Apigee accounts, see Creating an Apigee Account.
After you've signed up, you'll see that you have a sandbox application to experiment with. For more information about that, see Using a Sandbox Application.
Install Xcode for OS X
You'll need a mac running OS X and Xcode with support for iOS 5.0 or later installed to develop iOS apps.
Download the Apigee iOS SDK and expand the ZIP file.
When you expand the ZIP file, you should see the following structure:
apigee-ios-sdk-<version> /new-project-template /lib /samples /source README.md Contribution.txt LICENSE.txt
The SDK includes the following:
|File or Directory||Description|
|/lib||Framework of the SDK to import into your project.|
|/new-project-template||A simple template project that already integrates SDK files needed to build apps that support Apigee features.|
|/samples||Sample apps that you can run to explore Apigee features.|
|/source||Source code for the SDK, with classes grouped by area of functionality.|
If you've already got an Xcode iOS project, add it into your project as you normally would.
Locate the SDK framework file so you can add it to your project. For example, you'll find the file at the following path:
- In the Project Navigator, click on your project file, and then the Build Phases tab. Expand Link Binary With Libraries.
- Link the Apigee iOS SDK into your project.
- Drag ApigeeiOSSDK.framework into the Frameworks group created by Xcode.
- At the bottom of the Link Binary With Libraries group, click the + button. Then click Add Other.
- Navigate to the directory that contains ApigeeiOSSDK.framework, and choose the ApigeeiOSSDK.framework folder.
If you're starting with a clean slate (you don't have a project yet), you can begin by using the project template included with the SDK. The template includes support for SDK features.
Locate the project template in the expanded SDK. It should be at the following location:
- In the project template directory, open the project file: Apigee App Services iOS Template.xcodeproj.
- Get acquainted with the template by looking at its readme file.
Ensure that the following iOS frameworks are part of your project. To add them, under the Link Binary With Libraries group, click the + button, type the name of the framework you want to add, select the framework found by Xcode, then click Add.
In the Build Settings panel, add the following under Other Linker Flags:
Confirm that flags are set for both DEBUG and RELEASE.
The ApigeeClient class initializes the SDK. To do this you will need your organization name and application name, which are available in the Getting Started tab of the App Service admin portal, under Mobile SDK Keys.
- Import the SDK
Add the following to your source code to import the SDK:
Declare the following properties in
@property (strong, nonatomic) ApigeeClient *apigeeClient; //object for initializing the SDK @property (strong, nonatomic) ApigeeMonitoringClient *monitoringClient; //client object for Apigee App Monitoring methods @property (strong, nonatomic) ApigeeDataClient *dataClient; //client object for data methods
ApigeeClientclass inside the
//Replace 'AppDelegate' with the name of your app delegate class to instantiate it AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; NSString *orgName = @"YOUR-ORG"; NSString *appName = @"YOUR-APP"; //Instantiate ApigeeClient to initialize the SDK appDelegate.apigeeClient = [[ApigeeClient alloc] initWithOrganizationId:orgName applicationId:appName]; //Retrieve instances of ApigeeClient.monitoringClient and ApigeeClient.dataClient self.monitoringClient = [appDelegate.apigeeClient monitoringClient]; //used to call App Monitoring methods self.dataClient = [appDelegate.apigeeClient dataClient]; //used to call data methods
Once initialized, the SDK will also automatically instantiate the
ApigeeMonitoringClient class and begin logging usage, crash and error metrics for your app.
To verify that the SDK has been properly initialized, run your app, then go to 'Monitoring' > 'App Usage' in the admin portal to verify that data is being sent.
Call additional SDK methods in your code
Create an instance of the AppDelegate class, then use
appDelegate.monitoringClientto call SDK methods:
appDelegate.dataClient: Used to access the data methods of the SDK, including those for push notifications, data store, and geolocation.
appDelegate.monitoringClient: Used to access the app configuration and monitoring methods of the SDK, including advanced logging, and A/B testing.
For example, you could create a new entity with the following:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; ApigeeClientResponse *response = [appDelegate.dataClient createEntity:entity];
Add features to your app
With Apigee's API BaaS you can quickly add valuable features to your mobile or web app, including push notifications, a custom data store, geolocation and more. Check out these links to get started with a few of our most popular features:
- Push notifications: Send offers, alerts and other messages directly to user devices to dramatically increase engagement. You can send 10 million push notification per month for free!
- App Monitoring: When you initialize the SDK, a suite of valuable, customizable application monitoring features are automatically enabled that deliver the data you need to fine tune performance, analyze issues, and improve user experience.
- App Usage Monitoring: Visit the admin portal to view usage data for your app, including data on device models, platforms and OS versions running your app.
- API Performance Monitoring: Network performance is key to a solid user experience. In the admin portal you can view key metrics, including response time, number of requests and raw API request logs.
- Error & Crash Monitoring: Get alerted to any errors or crashes, then view them in the admin portal, where you can also analyze raw error and crash logs.
- Geolocation: Target users or return result sets based on user location to keep your app highly-relevant.
- Data storage: Store all your application data on our high-availability infrastructure, and never worry about dealing with a database ever again.
- User management and authentication: Every app needs users. You can easily implement user registration, as well as OAuth 2.0-compliant login and authentication.
Check out the sample apps
The SDK includes samples that illustrate Apigee features. To look at them, open the .xcodeproj file for each in Xcode. To get a sample app running, open its project file, then follow the steps described in the section, Add the SDK to an existing project.
You'll find the samples in the following location in your SDK download:
apigee-ios-sdk-<version> ... /samples
The samples include the following:
Sample Description books An app for storing a list of books that shows Apigee database operations such as reading, creating, and deleting. messagee An app for sending and receiving messages that shows Apigee database operations (reading, creating). push An app that uses the push feature to send notifications to the devices of users who have subscribed for them.
Help or comments?