2024-01-24 16:56:53 +01:00
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
|
|
|
|
|
|
class KillswitchService {
|
|
|
|
Future<bool> isKillswitchActive() async {
|
2024-01-31 11:56:38 +01:00
|
|
|
var packageInfo = await PackageInfo.fromPlatform();
|
|
|
|
var appName = packageInfo.appName;
|
2024-02-07 11:24:21 +01:00
|
|
|
http.Response response;
|
|
|
|
|
|
|
|
response = await http
|
2024-01-24 16:56:53 +01:00
|
|
|
.get(
|
|
|
|
Uri.parse('https://active-obelugnnza-uc.a.run.app/?appName=$appName'),
|
|
|
|
)
|
|
|
|
.timeout(
|
|
|
|
const Duration(seconds: 5),
|
|
|
|
onTimeout: () => http.Response('false', 500),
|
|
|
|
)
|
|
|
|
.onError(
|
|
|
|
(error, stackTrace) => http.Response('false', 500),
|
|
|
|
);
|
|
|
|
|
|
|
|
var decoded = jsonDecode(response.body);
|
|
|
|
|
|
|
|
if (decoded == true) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|