TopsortSDK for iOS
Overview
This is an API client generated by the OpenAPI Generator project.
- API version: 1.0.0
- Package version: 1.0.0
Installation
With Cocoapods
target MyApp do
pod 'TopsortSDK', '~> 1.0.0'
end
And run pod install
With Carthage
github "Topsort/CocoaSDK" ~> 1.0.0
And run carthage update
With Swift Packages
let package = Package(
dependencies: [
.package(url: "https://github.com/Topsort/CocoaSDK", from: "1.0.0"),
],
targets: [
.target(
name: "MyApp",
dependencies: ["TopsortSDK", ]
)
]
)
And run swift package update
Usage
With SwiftUI
Sending Hit Events whenever a product is tapped.
struct TopsortProduct : View {
var topsort: TopsortSDK
var product: Product
var body: some View {
MyProduct(...)
.onGestureTap() {
Task {
let event = HitEvent(,
productId: product.productId,
auctionId: product.auctionId,
resolvedBidId: product.resolvedBidId,
)
try? await topsort.logHitAsync(hitEvent)
}
}
}
}
Sending impression events when products are rendered.
struct Content : View {
var products: [Products]
var body: some View {
LazyVGrid(columns: columns, spacing: 2) {
ForEach(products, id: \self) { product in
TopsortProduct(product: product)
}
}
.task {
try? await topsort.logImpressionsAsync(impressions: products.map { p in
Impression(productId: p.productId, auctionId: p.auctionId, resolvedBidId: p.resolvedBidId)
})
}
}
}