From ad6355503bfa241f2cdafb7d3142c3d978c1af49 Mon Sep 17 00:00:00 2001 From: estevez-dev Date: Sun, 16 Jun 2019 00:23:11 +0300 Subject: [PATCH] WIP #48 Show dialog on app registration --- lib/home_assistant.class.dart | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart index eb0bde3..88a1699 100644 --- a/lib/home_assistant.class.dart +++ b/lib/home_assistant.class.dart @@ -119,8 +119,19 @@ class HomeAssistant { var responseObject = json.decode(response); SharedPreferences.getInstance().then((prefs) { prefs.setString("app-webhook-id", responseObject["webhook_id"]); + Connection().webhookId = responseObject["webhook_id"]; prefs.setString("registered-app-version", "$appVersion"); + Connection().registeredAppVersion = "$appVersion"; completer.complete(); + eventBus.fire(ShowDialogEvent( + title: "App was registered with your Home Assistant", + body: "To start using notifications you need to restart your Home Assistant", + positiveText: "Restart now", + negativeText: "Later", + onPositive: () { + Connection().callService(domain: "homeassistant", service: "restart", entityId: null); + }, + )); }); }).catchError((e) { completer.complete();