getCustomUserAgent method

Future<String> getCustomUserAgent()

Returns a custom User-Agent string based on the device info.

Implementation

Future<String> getCustomUserAgent() async {
  final deviceInfo = DeviceInfoPlugin();
  if (Platform.isAndroid) {
    final androidInfo = await deviceInfo.androidInfo;
    return 'Mozilla/5.0 (Linux; Android ${androidInfo.version.release}; ${androidInfo.model}) AppleWebKit/537.36 (KHTML, like Gecko) Mobile';
  } else if (Platform.isIOS) {
    final iosInfo = await deviceInfo.iosInfo;
    return 'Mozilla/5.0 (iPhone; CPU iPhone OS ${iosInfo.systemVersion.replaceAll('.', '_')} like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile';
  } else {
    return 'FlutterApp/1.0';
  }
}