Description:
According to the RevenueCat documentation, attributes are supposed to be synced with RevenueCat servers when Purchases.configure()
is called, the app is backgrounded, and when purchases are made or restored. However, in our Flutter app, we are encountering issues with attribute syncing and configuration:
-
Syncing on Configuration and App Backgrounding: We've noticed that attributes are not being synced with RevenueCat servers when
Purchases.configure()
is called or when the app is backgrounded. Despite following the documentation, attributes are only synced when purchases or restores are made. -
syncAttributesAndOfferingsIfNeeded()
Method Unavailable in Flutter SDK: The documentation mentions using thesyncAttributesAndOfferingsIfNeeded()
method for ensuring immediate syncing of custom attributes. However, this method seems to be available only for Android and Swift native code and is not accessible in the Flutter SDK. -
Issue with Existing Customers: We need to set attributes for existing customers in their profiles without requiring them to make a purchase again. However, with the current behavior, this seems challenging as attributes are only synced during purchase or restore events.
Example Code:
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
import 'store_config.dart';
void main() async {
if (Platform.isIOS || Platform.isMacOS) {
StoreConfig(store: Store.appStore, apiKey: appleApiKey);
} else if (Platform.isAndroid) {
StoreConfig(store: Store.playStore, apiKey: googleApiKey);
}
WidgetsFlutterBinding.ensureInitialized();
await _configureSDK();
await Purchases.setDisplayName("Cat");
await Purchases.setAttributes({"attributes": "testing"});
runApp(
MaterialApp(
home: Scaffold(
body: InkWell(
onTap: () {
Purchases.restorePurchases();
},
child: const Center(
child: Text("Restore Purchase"),
),
),
),
),
);
}
Future<void> _configureSDK() async {
await Purchases.setLogLevel(LogLevel.debug);
PurchasesConfiguration configuration = PurchasesConfiguration(StoreConfig.instance.apiKey)
..appUserID = null
..observerMode = false;
await Purchases.configure(configuration);
}
Package in pubspec.yaml File:
purchases_flutter: ^6.4.0
We would appreciate any guidance or assistance on how to address these issues and ensure that attributes are synced immediately upon configuration and app backgrounding in our Flutter app. Additionally, if there's a workaround or alternative approach to setting attributes for existing customers without making a purchase again, we would greatly appreciate your advice.
Thank you for your support.