Question

Issue with Attribute Syncing in RevenueCat Flutter SDK

  • 7 June 2024
  • 1 reply
  • 31 views

Badge +5

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:

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

  2. syncAttributesAndOfferingsIfNeeded() Method Unavailable in Flutter SDK: The documentation mentions using the syncAttributesAndOfferingsIfNeeded() 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.

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


This post has been closed for comments

1 reply

Userlevel 4
Badge +8

Hey, happy to help here.

I’m working on reproducing this now. In the meantime, could you provide debug logs (i.e., from when you configure the app with new attributes that need to be synced)? Also, is this just on 6.4.0, or does this still occur if you update to the latest 6.x.x version?