Integrate Flurry SDK for iOS

Important

We want you to know that all iOS Flurry SDKs are fully compliant with ATS since version 7.2.0 released September 2015. Flurry does not require any special exceptions to be added to your apps.

Integrating with the Flurry SDK is easy and straightforward for iOS developers.

Note

For more information on the working size of the Flurry iOS SDK in the App Store check out this article

Once you create an app and get your Flurry API Key, import Flurry libraries using CocoaPods for Swift and Objective-C Cocoa projects, add the required frameworks for Flurry integration, and finally initialize Flurry and start a Flurry session.

In no time at all, you’ll be ready to start logging events and publishing your ads.

Follow these instructions for either CocoaPods or manual integration. Swift integration steps are also provided.

Prerequisites: Xcode 8 and iOS 8 and higher.

As of Flurry SDK 8.0 the minimum support is for iOS 8. If you looking to release apps targeting devices on iOS 6 and/or iOS 7, email support@flurry.com and ask for Flurry SDK 7.10.0. Flurry SDK 7.10.0 it supports iOS 6 as the minimum OS version.

Create an App & Get Your API Keys

Start by creating an app. Once you create the app, you’ll receive a Flurry API Key, which you’ll need when using the SDK.

Important

You need to have the administrator role on your company’s account to be able to create a new app within the company.

Sign up  or  Create an App for iPhone

Note

For each distinct app that you create, you’ll need to acquire a unique Flurry API Key.

Import Flurry Libraries

Flurry recommends that you use CocoaPods to integrate the Flurry SDK, as it makes integrating and updating libraries faster, simpler and less prone to error.

CocoaPods

Flurry distributes the iOS SDKs via CocoaPods. CocoaPods is used to install and manage dependencies in existing Xcode projects.

To install the CocoaPods tool on OS X, enter this command from Terminal:

$ sudo gem install cocoapods

To add a Flurry SDK to your iOS app using CocoaPods, follow these steps:

  1. If you are not integrating Flurry into an existing project, create an Xcode project and save it to your local machine.
  2. Navigate to your project’s directory and create a Podfile by typing $ pod init.
  3. Open the Podfile and add your dependencies under your target. To integrate only Flurry Analytics, include only the Analytics Pod. To integrate Flurry Advertising, you must include both pods.
pod 'Flurry-iOS-SDK/FlurrySDK' #Analytics Pod
pod 'Flurry-iOS-SDK/FlurryAds' #Advertising Pod (requires Analytics)

Note

Remember to include use_frameworks! if your app target is in Swift.

  1. Run $ pod install in the directory containing the Podfile.
  2. Open your app’s .xcworkspace file to launch Xcode. Use this file for all development on your app.

For more information on working with CocoaPods, refer to the CocoaPods Getting Started guide

If you are looking to get Flurry SDK packaged in .a files, please email support@flurry.com and ask for the latest SDK be sent to you.

Swift SDK Integration

For Swift integration, you’ll need to implement a Bridging Header. Follow these steps if you are importing manually using Swift.

  1. Create the Bridging Header:
  • Click on your project’s subfolder (the folder with your app delegate, storyboard, and view controller under it).
  • Click File > New > File. You’ll be prompted to choose a template for your new file, which you will select Source under iOS along with Header File.
  1. Save the Bridging Header:
  • When prompted to save the file, name it using the following convention: projectname-Bridging-Header.h, where projectname is the name of your project.
  1. Expose the Bridging Header:
  • Select your project root and select Build Settings.
  • Make sure All not Basic is highlighted and then navigate to the Swift Compiler section.
  • Add the path to your Bridging Header as a key to the Objective-C Bridging Header item: projectname/projectname-Bridging-Header.h.

ios bridging header swift
  1. Import Objective-C libraries using the Bridging Header.
  • Select the Bridging Header file you created and add the import statements for each needed header file. The following bridging header example imports all Flurry libraries.
#ifndef IntegrationTest_Bridging_Header_h
#define IntegrationTest_Bridging_Header_h

//Needed for all Flurry Integration
#import "Flurry.h"

//Only needed for Flurry Advertising Integration
#import "FlurryAdBanner.h"
#import "FlurryAdBannerDelegate.h"
#import "FlurryAdDelegate.h"
#import "FlurryAdError.h"
#import "FlurryAdInterstitial.h"
#import "FlurryAdInterstitialDelegate.h"
#import "FlurryAdNative.h"
#import "FlurryAdNativeAsset.h"
#import "FlurryAdNativeDelegate.h"
#import "FlurryAdNativeStyle.h"
#import "FlurryAds.h"
#import "FlurryAdTargeting.h"

#endif /* IntegrationTest_Bridging_Header_h */

Initialize Flurry

To finish integrating Flurry, you’ll need to import Flurry in your Application Delegate and start a Flurry session inside applicationDidFinishLaunching, as described for Objective-C and Swift.

Addtional options for FlurrySessionBuilder:

- (FlurrySessionBuilder*) withAppVersion:(NSString *)value;

- (FlurrySessionBuilder*) withSessionContinueSeconds:(NSInteger)value;

- (FlurrySessionBuilder*) withCrashReporting:(BOOL)value;

- (FlurrySessionBuilder*) withLogLevel:(FlurryLogLevel) value;

- (FlurrySessionBuilder*) withShowErrorInLog:(BOOL) value;

- (FlurrySessionBuilder*) withTVSessionReportingInterval:(NSInteger) value;

- (FlurrySessionBuilder*) withTVEventCountThreshold:(NSInteger) value;

Now test run your app and ensure that it builds without errors. If everything is working properly, a session will be recorded in Flurry and should be visible on your Real Time dashboard within 30 seconds.

Important

If you created the Flurry app within the last 5 minutes, the app may not yet be live on our servers and thus will not reflect real-time data. Re-run your app after 5 minutes to see your session recorded on the Real Time dashboard.

FlurryDelegate

Starting version 6.3.0, Flurry analytics can take a delegate to callback on session getting created. A new protocol, FlurryDelegate is added to Flurry Analytics. The delegate object for Flurry needs to implement protocol, FlurryDelegate and need to be set as delegate using the following API call:

[Flurry setDelegate:<object that implements FlurryDelegate>];

Once delegate is set and the delegate responds to selector flurrySessionDidCreateWithInfo:, delegate gets callback on session getting created every time. The info provided in the callback is a NSDictionary object which contains data, “apiKey” and “sessionId”.

Congratulations! Your iOS app is now ready to be used with Flurry Analytics, and if you’ve integrated the Flurry Ads library, Flurry Advertising.

Integrating Other Analytics Features

Once you’ve completed the basic SDK integration setup, you’re can move on to Custom Events, Revenue Analytics, Crash Analytics, and other Advanced Features.

Need Help?

Check out our robust collection of FAQs and a detailed Lexicon of key terminology. Didn’t find what you were looking for? Check out the other options to get support.