A simple library for Vapor to fetch a users attribution record
import AAAttribution
let record: AAAttributionRecord = try await AAAttribution.fetchRecord(token, client: req.client)
if record.attribution {
// The API finds a matching attribution record
}
Getting the token on iOS
import AdServices
let token = try AAAttribution.attributionToken()
import Vapor
import Queues
import AAAttribution
struct AttributionBody: Content {
let token: String
...
}
struct AttributeUserInstallJob: AsyncJob {
typealias Payload = AttributionBody
func dequeue(_ context: QueueContext, _ payload: AttributionBody) async throws {
let record: AAAttributionRecord = try await context.application.attribution.fetchRecord(_ token: String)
...
}
func nextRetryIn(attempt: Int) -> Int {
return 5
}
}
Then dispatch a job
try await req.queue
.dispatch(AttributeUserInstallJob.self,
AttributionBody(token: "token"),
maxRetryCount: 3)