Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/topsort/cocoasdk


https://github.com/topsort/cocoasdk

Last synced: 15 days ago
JSON representation

Awesome Lists containing this project

README

        

# TopsortSDK for iOS

## Overview
This is an API client generated by the [OpenAPI Generator](https://openapi-generator.tech) project.

- API version: 1.0.0
- Package version: 1.0.0

## Installation

### With Cocoapods

```ruby
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

```swift
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.

```swift
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.

```swift
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)
})
}
}
}
```