Connect Apple Ads attribution with your own backend
No RevenueCat? Collect the token yourself, resolve attribution, and POST events to our webhook.
Collect the attribution token in-app
Use Apple's AdServices framework (iOS 14.3+). Send the token to your backend on app launch.
import AdServices
let token = try AAAttribution.attributionToken()
// POST { attributionToken: token, appUserId: uid } to your server
Use a MethodChannel to call native Swift — Dart doesn't expose AdServices directly. See Flutter docs.
Resolve attribution on your server
Call Apple's AdServices API with the token to get campaignId, adGroupId, keywordId, etc. Store the result linked to your user.
POST revenue events to ASAPilot
On purchase, renewal, cancellation, etc. — send a webhook from your server (never from the client):
POST /webhooks/custom-attribution
Authorization: Bearer <your-token>
Content-Type: application/json
{
"eventId": "evt_unique_id",
"eventType": "initial_purchase",
"user": { "appUserId": "user_123" },
"revenue": {
"productId": "pro_monthly",
"currency": "USD",
"price": 9.99
},
"attribution": {
"source": "APPLE_ADS",
"campaignId": 123456789,
"keywordId": 456789123
}
}
Use a stable eventId for idempotency. We return 200 on success. Retry on failure (5m, 10m, 1h).
Test it
Send a test event from your server, check ASAPilot, verify the data shows up. Start with sandbox, switch to production before launch.
Security: never expose the webhook auth token in the client app. Webhooks must come from your server only.