lookupByBundleId method

Future<Map?> lookupByBundleId(
  1. String bundleId, {
  2. String? country = 'US',
  3. bool useCacheBuster = true,
})

Look up by bundle id. Example: look up Google Maps iOS App: lookupURLByBundleId('com.google.Maps'); lookupURLByBundleId('com.google.Maps', country: 'FR');

Implementation

Future<Map?> lookupByBundleId(String bundleId,
    {String? country = 'US', bool useCacheBuster = true}) async {
  assert(bundleId.isNotEmpty);
  if (bundleId.isEmpty) {
    return null;
  }

  final url = lookupURLByBundleId(bundleId,
      country: country ??= '', useCacheBuster: useCacheBuster)!;
  if (debugLogging) {
    if (kDebugMode) {
      print('hcUpgrade: download: $url');
    }
  }

  try {
    final response = await client!.get(Uri.parse(url));
    if (debugLogging) {
      if (kDebugMode) {
        print('hcUpgrade: response statusCode: ${response.statusCode}');
      }
    }

    final decodedResults = _decodeResults(response.body);
    return decodedResults;
  } catch (e) {
    if (debugLogging) {
      if (kDebugMode) {
        print('hcUpgrade: lookupByBundleId exception: $e');
      }
    }
    return null;
  }
}