getProfile method

Future<AdaptyProfile> getProfile()

The main function for getting a user profile. Allows you to define the level of access, as well as other parameters.

The getProfile method provides the most up-to-date result as it always tries to query the API. If for some reason (e.g. no internet connection), the Adapty SDK fails to retrieve information from the server, the data from cache will be returned. It is also important to note that the Adapty SDK updates AdaptyProfile cache on a regular basis, in order to keep this information as up-to-date as possible.

Returns:

  • the result containing a AdaptyProfile object. This model contains info about access levels, subscriptions, and non-subscription purchases. Generally, you have to check only access level status to determine whether the user has premium access to the app.

Implementation

Future<AdaptyProfile> getProfile() async {
  final result = (await _invokeMethodHandlingErrors<String>(Method.getProfile)) as String;
  return AdaptyProfileJSONBuilder.fromJsonValue(json.decode(result));
}