setGroup method

Future<void> setGroup(
  1. String groupType,
  2. dynamic groupName
)

Adds a user to a group or groups. You need to specify a groupType and groupName(s). For example you can group people by their organization. In this case, groupType is "orgId", and groupName would be the actual ID(s). groupName can be a string or an array of strings to indicate a user in multiple groups. You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app). Note: This will also set groupType: groupName as a user property.

Implementation

/// For example you can group people by their organization. In this case,
/// groupType is "orgId", and groupName would be the actual ID(s).
/// groupName can be a string or an array of strings to indicate a user in multiple groups.

/// You can also call setGroup multiple times with different groupTypes to track
/// multiple types of groups (up to 5 per app).
/// Note: This will also set groupType: groupName as a user property.
Future<void> setGroup(String groupType, dynamic groupName) async {
  Map<String, dynamic> properties = _baseProperties();
  properties['groupType'] = groupType;
  properties['groupName'] = groupName;

  return await _channel.invokeMethod('setGroup', jsonEncode(properties));
}