syncAttributes method

  1. @override
Future<InappifySdkResult<List<Attribute>>> syncAttributes()
inherited

Synchronizes the complete attribute set for the active customer.

Implementation

@override
Future<InappifySdkResult<List<Attribute>>> syncAttributes() {
  return _run<List<Attribute>>(
    'syncAttributes',
    action: () async {
      if (_customerInfo == null) {
        final raw = await _bridge.call(
          'getCustomerInfo',
          positionalArguments: const <Object?>[
            'FETCH_CURRENT',
            <String, Object?>{},
          ],
        );
        _customerInfo = InappifyWebPayloadCodec.customerInfo(raw);
        _failedToLoadCustomerInfo = false;
      }
      final attributes = _currentAttributes;
      await _bridge.call(
        'syncAttributes',
        positionalArguments: <Object?>[
          InappifyWebPayloadCodec.attributeList(attributes),
        ],
      );
      _readCustomerPropertyBestEffort();
      return _currentAttributes;
    },
    mutationMayHaveCommitted: true,
  );
}