Flutter SDK

One integration for iOS + Android, in Dart. Persists via shared_preferences, talks plain HTTPS.

Install (pubspec)

YAML
dependencies:
  myappaffiliate_sdk: ^0.1.0
Shell
flutter pub get

Configure (once, at app startup)

Dart
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):

Dart
final appLinks = AppLinks();
appLinks.uriLinkStream.listen((uri) => MyAppAffiliate.attribute(uri));

Manual code (reliable everywhere — a creator's "LUMI"):

Dart
await MyAppAffiliate.applyCode('LUMI');

Identify the user

Use the same id you pass to RevenueCat (Purchases.logIn(...)):

Dart
await MyAppAffiliate.identify(userId);

Pass the affiliate into RevenueCat

Before the purchase, with purchases_flutter:

Dart
import 'package:purchases_flutter/purchases_flutter.dart';
 
final aff = await MyAppAffiliate.attributedAffiliateId();
if (aff != null) {
  await Purchases.setAttributes({'affiliate_id': aff});
}

API

CallPurpose
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.