Flutter SDK
One integration for iOS + Android, in Dart. Persists via shared_preferences, talks
plain HTTPS.
Install (pubspec)
dependencies:
myappaffiliate_sdk: ^0.1.0flutter pub getConfigure (once, at app startup)
import 'package:myappaffiliate_sdk/myappaffiliate_sdk.dart';
await MyAppAffiliate.configure(
apiKey: 'pk_live_…', // your app's SDK key
baseUrl: 'https://api.myappaffiliate.com',
);Attribute
Incoming link — with app_links (or uni_links), pass the URI through (the SDK
extracts the claim_token/ct param):
final appLinks = AppLinks();
appLinks.uriLinkStream.listen((uri) => MyAppAffiliate.attribute(uri));Manual code (reliable everywhere — a creator's "LUMI"):
await MyAppAffiliate.applyCode('LUMI');Identify the user
Use the same id you pass to RevenueCat (Purchases.logIn(...)):
await MyAppAffiliate.identify(userId);Pass the affiliate into RevenueCat
Before the purchase, with purchases_flutter:
import 'package:purchases_flutter/purchases_flutter.dart';
final aff = await MyAppAffiliate.attributedAffiliateId();
if (aff != null) {
await Purchases.setAttributes({'affiliate_id': aff});
}API
| Call | Purpose |
|---|---|
MyAppAffiliate.configure(apiKey:, baseUrl:) | Initialize once at startup |
MyAppAffiliate.attribute(uri) | Record attribution from an incoming link |
MyAppAffiliate.applyCode(code) | Manual-code attribution fallback |
MyAppAffiliate.identify(userId) | Bind your user id to the attribution |
MyAppAffiliate.attributedAffiliateId() | The attributed affiliate id (or null) |
All calls complete with false/null on network failure — the SDK never throws into
your app.