Datonomy SDK
This page shows you how to import, configure, and execute the DatonomySDK.
To get an API Key, send us an email at elton.soares@datonomy.tech.
Step 1: Preparing the project
To integrate the DatonomySDK through CocoaPods, first add the following line to your Podfile:
pod 'DatonomyKit'
Then run the following on the command line:
pod install --repo-update
Step 2: Initialize the SDK
Initialize the SDK in your app delegateโs application:applicationDidFinishLaunching: method.
import DatonomyKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
DatonomySdk()
.initialize(apiKey:"API_KEY",{(state, error) in
if error == nil {
print("SDK successfully initialized")
}
})
โฎ
Step 3: Sending Data points
Use the following code to send a impression:
let eventType = AdEventType.impression
let impression = AdImpression(revenue: 0.012, networkName: "Network Name", typeAds: .banner, currency: .BRL)
let event:AdEvent = AdEvent(type: eventType,impression: impression)
DatonomySdk().event(event: event,
{(sucess,error) in
if let sucess = sucess {
print("Data point session time successfully sent.")
}
}
)
Use the following code to send a session time:
let eventType = AdEventType.sessionTime
let sessionTimeInSecond = 200
let event:AdEvent = AdEvent(type: eventType, sessionTime: sessionTimeInSecond)
DatonomySdk().event(event: event,
{(sucess,error) in
if let sucess = sucess {
print("Data point session time successfully sent.")
}
}
)
Use the following code to send a transaction In-App Purchase:
let eventType = AdEventType.inAppPurchase
let transactionIAP= TransactionIAP(originalID: "0101", amount: 10.21,currency: .BRL)
let event:AdEvent = AdEvent(type: eventType, transactionIAP: transactionIAP)
DatonomySdk().event(event: event,
{(sucess,error) in
if let sucess = sucess {
print("Data point transaction IAP successfully sent.")
}
}
)
Step 4: Getting LTV Score
Use the following code to get LTV Score - sync:
do{
let score = try DatonomySdk().getLTVScore()
print("LTV Score retrieved successfully:\(score)")
}catch(let error){
print(error)
}
Use the following code to get LTV Score - async:
DatonomySdk().getLTVScore(
{(score,error) in
if let score = score {
print("LTV Score retrieved successfully:\(score)")
}
}
)
Last updated