checkForUpdates static method

Future<UpdateData> checkForUpdates({
  1. required String url,
  2. bool shouldPinCertificates = false,
  3. Map<String, String> httpHeaderFields = const {},
  4. Map<String, RequirementCheck> requirementChecks = const {},
})

Checks for application updates, by parsing the version configuration fetched from an url.

Returns UpdateData parsed from JSON version configuration. url - Url to the version configuration. shouldPinCertificates - iOS only. Indicates whether it should use security keys from all certificates found in the main bundle. Defaults to false. httpHeaderFields - iOS only. Http header fields. requirementChecks - Map of requirement keys and associated checks. A check determines if the value of the given requirement key satisfies the requirement. If the version configuration provides a requirement for which a RequirementCheck is not supplied, the requirement will be consider as not satisfied. Throws if it does not manage to fetch the version configuration.

Implementation

static Future<UpdateData> checkForUpdates({
  required String url,
  bool shouldPinCertificates = false,
  Map<String, String> httpHeaderFields = const {},
  Map<String, RequirementCheck> requirementChecks = const {},
}) async {
  _requirementsChannel.setMethodCallHandler((call) =>
      _handleRequirementsChannelMethodCall(call, requirementChecks));

  final data = await _channel.invokeMethod(
    Constants.checkForUpdatesMethodName,
    [
      url,
      shouldPinCertificates,
      httpHeaderFields,
      requirementChecks.keys.toList(),
    ],
  ) as Map<dynamic, dynamic>;

  return UpdateData._fromMap(data);
}