amos_flutter 2.0.0
amos_flutter: ^2.0.0 copied to clipboard
Provider-neutral Flutter bridge for the AMOS monetization SDK.
AMOS Flutter Core #
Provider-neutral Flutter access to the AMOS Kotlin core on Android.
The repository contains a separate Android integration lab for AMOS release verification. It is intentionally excluded from the published package.
Requirements #
- Flutter 3.19 or newer
- Android API 24 or newer
com.amostack:amos-sdk:2.0.0available from Maven Central
Install #
dependencies:
amos_flutter: ^2.0.0
Initialize #
Initialize after your app knows the signed-in account. externalUserId must be a stable ID from your account system, not an email address. AMOS maps it to its own internal user ID and the underlying Kotlin SDK persists that mapping.
final amos = AmosClient.instance;
final state = await amos.initialize(
const AmosConfiguration(
apiKey: 'amos_api_key',
appId: 'app_id',
externalUserId: 'account_48291',
debug: true,
),
);
Initialization starts or resumes the AMOS session. By default, Flutter lifecycle changes are forwarded automatically. Returning after 30 minutes starts a new session; returning sooner refreshes stale configuration after five minutes.
Events and metrics #
await amos.trackEvent('level_completed');
await amos.trackMetric('subscription_value', 9.99);
Only events and metrics allowed by the current AMOS configuration are accepted.
Decisions and remote config #
final decision = await amos.getDecision();
if (decision.ads.interstitialEnabled) {
// Ask your provider adapter to load/show an interstitial.
}
final remoteConfig = await amos.getRemoteConfig();
final featureEnabled = amos.remoteValue(remoteConfig, 'new_checkout', false);
This core package does not render ads. Add a separate provider package when one is required.
Paywalls #
final paywall = await amos.getPaywallDecision('premium_entry');
if (paywall.shouldShow) {
await amos.recordPaywallShown(paywall.placement);
// Present the app-owned paywall.
}
Call recordPaywallDismissed after dismissal so AMOS can enforce policy correctly.
Explicit session controls #
await amos.refreshConfiguration();
await amos.endSession();
Set AmosLifecycleConfig(automatic: false) only when the host app will call appBackgrounded and appForegrounded itself.