Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Tracking Features in watchOS Native Apps in 3 Steps

DZone's Guide to

Tracking Features in watchOS Native Apps in 3 Steps

The Pyze watchOS SDK can be used to add event tracking to your Native mobile watch application. This tutorial shows you how to integrate the watchOS SDK.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

Recently, eBay, Google, and Amazon removed their watchOS apps from the app stores, and are expected to bring revised and reworked versions back in the future. We saw similar failures of first generation mobile apps that were ported from the web.

watchOS apps have to be designed for the watch, keeping in mind the engagement times amongst other features. Typical engagement times, for instance, on a watchOS app is 11-14 seconds for app usage and 1-2 seconds for glances.  Compare that to 51 seconds for a mobile app and tens of minutes for a web app.

When designing a watchOS app it is important to limit to essential features. To figure out what features are being utilized and which ones are not, you need to track usage and user behavior of your watchOS app.  

This article shows how easy it is for developers to integrate Pyze watchOS SDK in your app and track events in 3 steps.

1. Integrate watchOS SDK Using Cocoapods

The instructions to get started with watchOS are available at watchOS.pyze.com.

We will install using Cocoapods.

  1. Locate your watchOS app in Finder and open ‘Terminal’ application on macOS and ‘cd’ to the application folder source.
  2. Execute ‘pod init‘,  open the pod file created under the folder and add ‘pyze-sdk-watchOS’ before the ‘end’ command of ‘WatchKit Extension’ target. Save and close it.
  3. In Terminal, execute the ‘pod install’ command; this will download and auto-integrate the Pyze SDK for watchOS to your app’s extension source code.
  4. Open your browser and go to ‘growth.pyze.com’ and create a new app and copy the Pyze App Key (instructions).
  5. You will need the key below when initializing the Pyze watchOS SDK.

2. Initialize

Open the ExtensionDelegate.swift file and add the following line in the applicationDidFinishLaunching method (instructions).

    func applicationDidFinishLaunching() {
        Pyze.initialize("Get a key from growth.pyze.com",
                        withLogThrottling: .PyzelogLevelMinimal)
    }

Image title

3. Add an Example Event

Let’s add an “Ad Clicked” event.  This is just a demonstration of one event out of many possible events defined in the PyzeEvents class.

- (IBAction)didTapAd {
    [PyzeAd postAdClicked:@"AdClicked"
            fromAppScreen:@"Home"
                   adCode:@"1234"
                isSuccess:YES
            withErrorCode:nil
           withAttributes:@{@"abc" : @"pqr", @"xyz" : @"123"}];
}

Image title

Sample Code

You can alternatively use the following sample code: Source Code.

  1. You will need to get your own key from growth.pyze.com (Here are the instructions for getting a Pyze App Key).
  2. Close Xcode project.
  3. Run a pod update.
  4. Open Xcode project using TestAppWatch.xcworkspace.
  5. Run the TestAppWatch WatchKit App.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
watchos ,pyze ,mobile ,wearables ,app development ,apple watch

Published at DZone with permission of Ram Naragund. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}