First-launch setup
One fetch on first open makes every later purchase match the exact ad that drove it. No SDK from us.
Attribution works from links + the webhook alone. This snippet sharpens it: it sends the device signal set so we pick the right click, then hands the resolved click id to RevenueCat so every future purchase is deterministic.
The snippet
Paste once where your app starts, right after RevenueCat is configured:
// On first launch, after Purchases.configure(...)
import UIKit
func makervnModel() -> String { // e.g. "iPhone15,2"
var s = utsname(); uname(&s)
return withUnsafeBytes(of: &s.machine) { String(cString: $0.bindMemory(to: CChar.self).baseAddress!) }
}
var c = URLComponents(string: "https://www.makervn.app/api/attribution/resolve")!
c.queryItems = [
.init(name: "app", value: "YOUR_APP_TOKEN"),
.init(name: "uid", value: Purchases.shared.appUserID), // RevenueCat fills this
.init(name: "platform", value: "ios"),
.init(name: "osVersion", value: UIDevice.current.systemVersion),
.init(name: "model", value: makervnModel()),
.init(name: "lang", value: Locale.current.language.languageCode?.identifier),
]
if let (data, _) = try? await URLSession.shared.data(from: c.url!),
let j = try? JSONSerialization.jsonObject(with: data) as? [String: Any] {
if let cid = j["cid"] as? String { Purchases.shared.attribution.setAttributes(["makervn_cid": cid]) }
// if let deep = j["deep_link"] as? String { /* route the user to `deep` */ }
}What it sends and returns
- Sends —
app(your token),uid(RevenueCat's app user id), and the device signals:platform,osVersion,model,lang. - Returns —
{ cid, confidence, tier, channel, campaign, deep_link }. Setcidas themakervn_cidRevenueCat attribute;deep_linkis for deferred deep linking.
Your app token
The token is the same value embedded in your webhook URL (Dashboard → Integrations → RevenueCat → Connect). It identifies the app; it is not a secret API key, and the uid is provided by RevenueCat at runtime.
Skip it?
You'll still get attribution and billing from the webhook — just at a lower confidence, matched from signals rather than the exact click.