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:
<sdk_root>/bin/ApigeeiOSSDK.framework
OR
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:
<sdk_root>/new-project-template
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:
-ObjC -all_load
Confirm that flags are set for both DEBUG and RELEASE.
The ApigeeClient class initializes the App Services 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.
Add the following to your source code to import the SDK:
#import <ApigeeiOSSDK/Apigee.h>
Declare the following properties in
AppDelegate.h
:
@property (strong, nonatomic) ApigeeClient *apigeeClient; @property (strong, nonatomic) ApigeeMonitoringClient *monitoringClient; @property (strong, nonatomic) ApigeeDataClient *dataClient;
Instantiate the
ApigeeClient
class inside the
didFinishLaunching
method of
AppDelegate.m
:
//Replace 'AppDelegate' with the name of your app delegate class to instantiate it AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; //Sepcify your App Services organization and application names NSString *orgName = @"{{currentOrg}}"; NSString *appName = @"{{currentApp}}"; //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]; self.dataClient = [appDelegate.apigeeClient dataClient];
Once initialized, App Services 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 App Services admin portal to verify that data is being sent.
Create an instance of the AppDelegate class, then use
appDelegate.dataClient
or
appDelegate.monitoringClient
to call SDK methods:
appDelegate.dataClient
: Used to access the
data methods of the App Services SDK, including those for push
notifications, data store, and geolocation.appDelegate.monitoringClient
: Used to
access the app configuration and monitoring methods of the App
Services 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];
With App Services 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:
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. |