The Swaarm iOS SDK will allow you to track installs, events, re-engagements and much more in your iOS app. Follow the steps below in this guide to set up your app to work with the Swaarm SDK. You can find the Swaarm iOS SDK on Github.
⚠️ Important:
Swaarm SDK supports iOS 10 or higher
Step 1: Setting up your Environment
In order to start using the Swaarm SDK, it first needs to be added to your project. This can be done in one of the two following methods:
Swift Package
Swift Package
Go to XCode
Select File
Select Add Package
In the box, search by adding Swaarm's SDK url
https://github.com/swaarm/iOS-sdk
Select the SDK
Framework
Framework
You can manually integrate the Swaarm SDK to your app by adding it as a framework.
Go to Swaarm SDK releases page
Download the latest framework version
Unzip the file
Copy the
.framework
folder to your XCode project
Step 2: Import and Initialise the SDK
You can import and initialise the Swaarm SDK into your project using either Swift or Objective-C. To initialise the Swaarm SDK, you would require the host and a token which would be made available to you after Swaarm account creation by the Swaarm Team. The token can be generated in the Swaarm platform for each Store App.
The initialisation of the Swaarm SDK needs to be done in the startup method of your app. For example: in the init
function of your swiftui app, or the willFinishLaunchingWithOptions
function or didFinishLaunchingWithOptions
function. Doing so will enable us to track installs and sessions automatically.
The Swaarm SDK automatically detects if an app was installed before on first start. If it's indeed a reinstall, an event marking the reinstall will be sent in lieu of a normal install.
✏️ Note:
To get additional logs and debug output, set debug to true
Swift
import SwaarmSdk
SwaarmAnalytics.configure(token: "123456", host: "https://tracker-domain.com", debug: true)
SwaarmAnalytics.event(typeId: "event_type_id", aggregatedValue: 123D, customValue: "custom value", revenue: 12.1)
SwaarmAnalytics.purchase(typeId: "event_type_id", revenue: 12.0, currency: "USD", receipt: "base64 receipt or transactionId")
Objective-C
@import SwaarmSdk;
[SwaarmAnalytics configureWithToken: @"123456" host: @"https://tracker-domain.com" batchSize:10 flushFrequency: 10 maxSize: 50 debug: YES];
[SwaarmAnalytics eventWithTypeId:@"eventTypeId" aggregatedValue:0.0 customValue:@"custom" revenue:0.0];
[SwaarmAnalytics purchaseWithTypeId:@"eventTypeId" revenue:0.0 currency:@"USD" receipt:@"base64 receipt or transactionId"];
⚠️ Important:
It is essential to initialise the Swaarm SDK in the way and in one of the functions described above to avoid unexpected results.
The events tracked by the SDK will be automatically enriched with device and location data. The user is identified in the Swaarm platform using the IDFV parameter. The IDFA also collected, if the app has requested app tracking authorisation and the user has granted it.
✏️ Note:
On devices using iOS 14 and up, tracking needs to be specifically requested to be able to get a non-zero idfa. To enable the idfa, tracking needs to be requested from a visible app. More information on this can be found here.
Step 3: Build your App and Publish it
Congratulations, you are now ready to build, run and distribute your app. Swaarm SDK is all set to start tracking your events and attributing them!