Integrating watchOS Pyze SDK in your native watchOS App

Integrate Pyze watchOS SDK using Cocoapods

The instructions to get started 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 your 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 ‘pod install’ command, this will download and auto integrate the Pyze SDK for watchOS to the 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 Pyze watchOS SDK

Initialize Pyze

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

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

Add an example event

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

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

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

screen-shot-2017-01-30-at-10-34-21-pm

watch-series-2-stainless-steel-white-sport

Learn more about Pyze and Signup here