Integrate Flurry SDK for Apple Watch

If you’ve integrated your iOS app with Flurry Analytics that uses an Apple Watch Extension, you can add Flurry Analytics for the Apple Watch.

Follow these steps to track and receive analytics from your Apple Watch Extension related to New Users, Active Users and Custom Eventing.

Before You Begin

Make sure you have successfully integrated Flurry Analytics into your iOS app by following the steps outlined in the Integrate Flurry SDK for iOS section. For Watch analytics, the optional Flurry Advertising library is not necessary.

Create a Watch Extension

If you have not yet added a watch extension to your iOS app with Flurry Analytics, follow these quick instructions to create one.

  1. Create the Extension:

  • Select your project root and then click File > New > Target.

  • Now select watchOS > Application > WatchKit App and click Next.

watchkit os
  1. Name the Extension:

  • Choose a name for your watch app and click Finish.

  1. Activate the Extension:

  • A popup appears, asking if you want to activate your watch app scheme.

  • Choose Activate.

Import Flurry Libraries

When you integrated the main Flurry SDK for iOS, you either used CocoaPods or you integrated manually. Follow these steps based on how you integrated the Flurry SDK for iOS.

  1. Link the Flurry Watch Library:

If you integrated using CocoaPods:

Import the Watch SDK: In your podfile, under the Watch extension target, add the Watch SDK and run pod install.

For the Apple Watch 2.x Extension:

target :“Your Apple Watch 2.x Extension Target” do
pod ‘Flurry-iOS-SDK/FlurryWatchOSSDK’
platform :watchos, ‘2.0’
end

Write an Import Statement: To import the Flurry libraries into your Watch Extension, include an import statement at the top of any file using the Flurry Watch library:

import Flurry_iOS_SDK
  1. Link the Watch Connectivity Framework:

  • Click on your project, then under the Projects and Targets List, select your Watch Extension target. Now click Build Phases and look under Link Binary with Libraries.

  • Click the “+” button and add the WatchConnectivity.framework.

Enable Extensions

To get started tracking Events and comparing usage between your app and its Apple Watch extension, follow these steps:

  1. Generate an Extension Key: For any iPhone app in your portfolio, navigate to the Admin > Applications page and click the Get Extension Key button . An Extension Key is generated and presented in place of the button.


watch extension key
  1. Add the Extension Key to your Watch Extension’s plist File: In your Xcode project, open the plist and include a key for the Flurry Watch API Key. This should include the Watch Extension Key created via the process described above.


watchos api key

Important

Use caution when entering API Keys and Watch Extension Keys into your app code. The incorrect placement of keys will result in invalid metrics.

  1. Optionally, configure these additional keys:

  • Flurry Watch App Version. The version of the your app.

  • Flurry Watch Event Threshold. The maximum time a watch session can exist before being sent to the server. Note that the default value for this is 10 events. There is also a minimum threshold of 5 events and a maximum of 50 events that are limits on this property.

  • Flurry Watch Duration Threshold. The maximum number of events that will be recorded in a watch session before being sent to the server. The default value for this property is 10 minutes. 5 minutes is the minimum and 60 minutes is the maximum.

  • Flurry Watch Debug. Set this to YES to enable debug logs as shown below.


watch debug

Store Watch Properties in a plist

Unlike a standard iOS app, which has a single point of entry (AppDelegate), WatchKit extensions have multiple points of entry. InterfaceControllers, NotificationControllers, and GlanceControllers can all be called without going through a common piece of code.

To avoid having to repeatedly set these values in every WKInterfaceController, they are set in one place.

Watch sessions behave differently due to the nature of the WKInterfaceController life cycles. There is no clear indication of when a user has stopped using the Watch. With the flip of a wrist, they can start and stop watch interactions.

To avoid creating large numbers of minuscule sessions, Flurry keeps sessions alive until they reach a particular duration or event-based thresholds. Once the thresholds are reached, the session ends and a new session begins on the next event.

Verify Integration

To insure you integrated the Flurry Watch SDK correctly, create a test event in your ExtensionDelegate.swift file under applicationDidFinishLaunching like so:

For Objective-C

#import "Flurry.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
           [FlurryWatch logWatchEvent:@"WatchFinishedLaunchingTestEvent"];
}

For Swift

import Flurry_iOS_SDK //only needed if SDK was integrated using Cocoapods

func applicationDidFinishLaunching() {
      // Perform any final initialization of your application.
      FlurryWatch.logWatchEvent("WatchFinishedLaunchingTestEvent")
}

Now test run your app and ensure it builds without errors. If all is working, a session will be recorded in Flurry and should be visible in your Application’s Extensions tab within 8 hours.

Your Watch Extension app is now ready to be used with Flurry Analytics for Apple Watch, navigate to the Analytics documentation to learn how to log events.

Need Help?

Check out our robust collection of FAQs and a detailed Lexicon of key terminology. Didn’t find what you were looking for? Contact support@flurry.com for additional support.