Collecting Usage Statistics

Track key performance indicators (KPIs) such as device types, operating systems, and SDKs.


The SDK components automatically log some predefined events and metrics. You can also log custom-defined timers, events, and measurements.

To collect statistics, you need the iOS Native Client SDK libraries, which are available as part of the SAP Mobile Platform Client SDK Installer. The Usage library ships in the form of separate artifacts, such as statically linked libraries and public header files.

If the server on which statistics are being collected uses a HANA database, the database must use a flexible schema.

Before you can use the Usage library, you must add associated artifacts to your project. You must also add dependent frameworks and configure your build settings. If you are working with an existing project rather than creating a new one, the steps may differ.


  1. In Xcode, create a new project or open an existing one.
  2. Set the Bundle Identifier and the Version Number in Start of the navigation path Project Settings Next navigation step General End of the navigation path.
    See Setting the Bundle ID and Setting the Version Number and Build String in the Apple Developer documentation at published on non-SAP site for details.
  3. Drag these Usage artifacts into your project:
    • libUsage.a
    • libsqlcipher.a
    • libssl.a
    • libcrypto.a
  4. To enable the Usage to automatically upload the created logs, add:
    • libHttpConversation.a
    • libHttpConvAuthFlows.a
  5. Select your project from the Project Navigator, and choose your application's target.
  6. Open the Build Phases tab and, within Link Binary with Libraries, add SystemConfiguration.framework.
  7. Choose your project, rather than a specific target, and open the Build Settings tab.
    1. In the Other Linker Flags section, add -ObjC and -all_load. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
    2. In the header search path section, adjust the path to look for public header files. Depending on where you copied the header files, the path string should look something like this:
    3. In the library search path section, adjust the path to look for the binary files. Depending on where you copied the library files, the path string should look something like this:
  8. Add the HttpConvAuthFlows.bundle to your project.
  9. Implement the necessary code.
    1. Initialize the Usage library:
      [Usage initUsageWithURL:[NSURL URLWithString:urlForRequest] httpConversationManager:manager];
      To encrypt the database, use this API call:
      [Usage initUsageWithURL:[NSURL URLWithString:urlForRequest] httpConversationManager:manager dataEncryptionKey:key];
    2. After initialization, you can start timers to measure certain events. Here is an example to start a timer when the MasterViewController is loaded:
      -(void)viewDidAppear: (BOOL)animated{
      	[super viewDidAppear:animated];
      	[Usage timeStart:@"MasterViewController"];
    3. Stop the timer, for example, if the user is navigates to the detail view:
      - (void)viewDidLoad
          [super viewDidLoad];
          [self configureView];
          [Usage timeEnd:@"MasterViewController"];
    4. To manage the timer instance, start and get a Timer object by calling:
    5. Stop and persist a timer:
      +(void)stopTimer:(Timer *)timer;
    6. To log an event, for example, when an item is added or a button is pressed, you can use the log APIs:
      NSMutableDictionary* info = [[NSMutableDictionary alloc]init];
          for (int i= 0; i<[_objects count]; i++) {
              [info setValue:[[_objects objectAtIndex:i] description]  forKey:[NSString stringWithFormat:@"%i",i]];
          [Usage log:@"New item added"info:info type:@"itemList"];