Skip to main content
Question

Issue with Attribute Syncing in RevenueCat Flutter SDK

  • June 7, 2024
  • 1 reply
  • 80 views

Forum|alt.badge.img+5
  • New Member
  • 1 reply

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

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 383 replies
  • June 11, 2024

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?


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings