Integrate Pyze watchOS SDK using Cocoapods
The instructions to get started are available at watchOS.pyze.com.
We will install using Cocoapods.
- Locate your watchOS app in finder and open ‘Terminal’ application on macOS and ‘cd’ to the your application folder source.
- 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.
- 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.
- Open your browser and go to ‘growth.pyze.com’ and create a new app and copy the Pyze App Key (instructions)
- 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
- You will need to get your own key from growth.pyze.com (Here are the instructions for getting a Pyze App Key)
- Close Xcode project
- Run a pod update
- Open Xcode project using TestAppWatch.xcworkspace
- Run the TestAppWatch WatchKit App
Learn more about Pyze and Signup here