Remove mobile app integration version check
This commit is contained in:
parent
9608983994
commit
a8efe7dbb6
@ -23,7 +23,6 @@ class AppSettings {
|
|||||||
String fcmToken;
|
String fcmToken;
|
||||||
double haVersion;
|
double haVersion;
|
||||||
bool scrollBadges;
|
bool scrollBadges;
|
||||||
int appIntegrationVersion;
|
|
||||||
AppTheme appTheme;
|
AppTheme appTheme;
|
||||||
final int defaultLocationUpdateIntervalMinutes = 20;
|
final int defaultLocationUpdateIntervalMinutes = 20;
|
||||||
Duration locationUpdateInterval;
|
Duration locationUpdateInterval;
|
||||||
@ -46,7 +45,6 @@ class AppSettings {
|
|||||||
_port = prefs.getString('hassio-port');
|
_port = prefs.getString('hassio-port');
|
||||||
webhookId = prefs.getString('app-webhook-id');
|
webhookId = prefs.getString('app-webhook-id');
|
||||||
mobileAppDeviceName = prefs.getString('app-integration-device-name');
|
mobileAppDeviceName = prefs.getString('app-integration-device-name');
|
||||||
appIntegrationVersion = prefs.getInt('app-integration-version') ?? 0;
|
|
||||||
scrollBadges = prefs.getBool('scroll-badges') ?? true;
|
scrollBadges = prefs.getBool('scroll-badges') ?? true;
|
||||||
displayHostname = "$_domain:$_port";
|
displayHostname = "$_domain:$_port";
|
||||||
webSocketAPIEndpoint =
|
webSocketAPIEndpoint =
|
||||||
|
@ -2,8 +2,6 @@ part of '../main.dart';
|
|||||||
|
|
||||||
class MobileAppIntegrationManager {
|
class MobileAppIntegrationManager {
|
||||||
|
|
||||||
static const INTEGRATION_VERSION = 3;
|
|
||||||
|
|
||||||
static final _appRegistrationData = {
|
static final _appRegistrationData = {
|
||||||
"device_name": "",
|
"device_name": "",
|
||||||
"app_version": "$appVersion",
|
"app_version": "$appVersion",
|
||||||
@ -49,10 +47,8 @@ class MobileAppIntegrationManager {
|
|||||||
Logger.d("Processing registration responce...");
|
Logger.d("Processing registration responce...");
|
||||||
var responseObject = json.decode(response);
|
var responseObject = json.decode(response);
|
||||||
AppSettings().webhookId = responseObject["webhook_id"];
|
AppSettings().webhookId = responseObject["webhook_id"];
|
||||||
AppSettings().appIntegrationVersion = INTEGRATION_VERSION;
|
|
||||||
AppSettings().save({
|
AppSettings().save({
|
||||||
'app-webhook-id': responseObject["webhook_id"],
|
'app-webhook-id': responseObject["webhook_id"]
|
||||||
'app-integration-version': INTEGRATION_VERSION
|
|
||||||
}).then((prefs) {
|
}).then((prefs) {
|
||||||
completer.complete();
|
completer.complete();
|
||||||
eventBus.fire(ShowPopupEvent(
|
eventBus.fire(ShowPopupEvent(
|
||||||
@ -98,12 +94,7 @@ class MobileAppIntegrationManager {
|
|||||||
Logger.w("No registration data in response. MobileApp integration was removed or broken");
|
Logger.w("No registration data in response. MobileApp integration was removed or broken");
|
||||||
_askToRegisterApp();
|
_askToRegisterApp();
|
||||||
} else {
|
} else {
|
||||||
if (INTEGRATION_VERSION > AppSettings().appIntegrationVersion) {
|
Logger.d('App registration works fine');
|
||||||
Logger.d('App registration needs to be updated');
|
|
||||||
_askToRemoveAndRegisterApp();
|
|
||||||
} else {
|
|
||||||
Logger.d('App registration works fine');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
completer.complete();
|
completer.complete();
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
@ -137,20 +128,6 @@ class MobileAppIntegrationManager {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _askToRemoveAndRegisterApp() {
|
|
||||||
eventBus.fire(ShowPopupEvent(
|
|
||||||
popup: Popup(
|
|
||||||
title: "Mobile app integration needs to be updated",
|
|
||||||
body: "You need to update HA Client integration to continue using notifications and location tracking. Please remove 'Mobile App' integration for this device from your Home Assistant and restart Home Assistant. Then go back to HA Client to create app integration again.",
|
|
||||||
positiveText: "Ok",
|
|
||||||
negativeText: "Report an issue",
|
|
||||||
onNegative: () {
|
|
||||||
Launcher.launchURLInBrowser("https://github.com/estevez-dev/ha_client/issues/new");
|
|
||||||
},
|
|
||||||
)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _askToRegisterApp() {
|
static void _askToRegisterApp() {
|
||||||
eventBus.fire(ShowPopupEvent(
|
eventBus.fire(ShowPopupEvent(
|
||||||
popup: RegisterAppPopup(
|
popup: RegisterAppPopup(
|
||||||
|
Reference in New Issue
Block a user