WIP #471 Native FCM init

This commit is contained in:
Yegor Vialov
2020-05-24 12:42:31 +00:00
parent 3fdf016c39
commit d3f99fb262
9 changed files with 54 additions and 69 deletions

View File

@ -20,6 +20,7 @@ class AppSettings {
String tempToken;
String oauthUrl;
String webhookId;
String fcmToken;
double haVersion;
bool scrollBadges;
int appIntegrationVersion;
@ -40,6 +41,7 @@ class AppSettings {
if (full) {
Logger.d('Loading settings...');
SharedPreferences prefs = await SharedPreferences.getInstance();
fcmToken = prefs.getString('fcm-token');
_domain = prefs.getString('hassio-domain');
_port = prefs.getString('hassio-port');
webhookId = prefs.getString('app-webhook-id');

View File

@ -12,7 +12,7 @@ class MobileAppIntegrationManager {
"os_version": DeviceInfoManager().osVersion,
"app_data": {
"push_token": "",
"push_url": "https://us-central1-ha-client-c73c4.cloudfunctions.net/pushNotifyV2"
"push_url": "https://us-central1-ha-client-c73c4.cloudfunctions.net/pushNotifyV3"
}
};
@ -26,7 +26,7 @@ class MobileAppIntegrationManager {
static Future checkAppRegistration() {
Completer completer = Completer();
_appRegistrationData["device_name"] = AppSettings().mobileAppDeviceName ?? getDefaultDeviceName();
(_appRegistrationData["app_data"] as Map)["push_token"] = "${HomeAssistant().fcmToken}";
(_appRegistrationData["app_data"] as Map)["push_token"] = "${AppSettings().fcmToken}";
if (AppSettings().webhookId == null) {
Logger.d("Mobile app was not registered yet. Registering...");
var registrationData = Map.from(_appRegistrationData);