Get TelemetryClient
This concludes the preparation. Let's add TelemetryDeck to your app! Open Xcode and navigate to the project you want to add TelemetryDeck to.
In the menu, select File -> Add Packages.... This will open the Swift Package Manager view. Add the following as package repository and click Next:
https://github.com/TelemetryDeck/SwiftClient
There will be one or two additional screens, but you can just click Next and Finish on them – Xcode will do the right thing of linking the package against your target. (In the unlikely case that you have multiple targets, link them each with the package's library.)
This will include the TelemetryDeck Swift Client into your app by downloading the source code. Feel free to browse the client's source code, it's very tiny and you'll see for yourself how TelemetryDeck is hashing user identifers before they ever reach the server. Privacy, yay!
Coding Time!
The TelemetryClient
package will provide you with a class TelemetryManager
that you'll use for all interaction with TelemetryDeck. Before you can use that class, you'll need to initialize it at the start of your app. I strongly recommend doing so as soon as possible, as you won't be able to send Signals before the TelemetryManager
is initialized.
This is slightly different depending on wether you use SwiftUI or UIKit's AppDelegate
to manage your app's lifecycle, so let's look at these individually. Please select the one that applies: