diff --git a/android/app/build.gradle b/android/app/build.gradle
index f900f88..191fe16 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -70,7 +70,10 @@ flutter {
}
dependencies {
+ implementation 'com.google.firebase:firebase-core:16.0.8'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
+
+apply plugin: 'com.google.gms.google-services'
diff --git a/android/app/google-services.json b/android/app/google-services.json
new file mode 100644
index 0000000..37d87eb
--- /dev/null
+++ b/android/app/google-services.json
@@ -0,0 +1,42 @@
+{
+ "project_info": {
+ "project_number": "441874387819",
+ "firebase_url": "https://ha-client-c73c4.firebaseio.com",
+ "project_id": "ha-client-c73c4",
+ "storage_bucket": "ha-client-c73c4.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:441874387819:android:92c7efc892dc3d45",
+ "android_client_info": {
+ "package_name": "com.keyboardcrumbs.haclient"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "441874387819-id0hqsfprj3b5kc312faqv3lmdfpm7l8.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyBsl9cjBY633IrdrTyCsLFlO9lfsYJ0OJU"
+ }
+ ],
+ "services": {
+ "analytics_service": {
+ "status": 1
+ },
+ "appinvite_service": {
+ "status": 1,
+ "other_platform_oauth_client": []
+ },
+ "ads_service": {
+ "status": 2
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 5235bb5..53e7a14 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -30,6 +30,10 @@
+
+
+
+
diff --git a/android/build.gradle b/android/build.gradle
index d4225c7..39e97d4 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -5,7 +5,8 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.2'
+ classpath 'com.android.tools.build:gradle:3.3.2'
+ classpath 'com.google.gms:google-services:4.2.0'
}
}
diff --git a/android/gradle.properties b/android/gradle.properties
index 9e00b35..aec424e 100644
--- a/android/gradle.properties
+++ b/android/gradle.properties
@@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx2g
org.gradle.daemon=true
org.gradle.caching=true
android.useAndroidX=true
-android.enableJetifier=false
\ No newline at end of file
+android.enableJetifier=true
\ No newline at end of file
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
index 9372d0f..77e79b8 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
diff --git a/lib/home_assistant.class.dart b/lib/home_assistant.class.dart
index 8369428..d405e40 100644
--- a/lib/home_assistant.class.dart
+++ b/lib/home_assistant.class.dart
@@ -578,6 +578,22 @@ class HomeAssistant {
return [];
}
}
+
+ Future sendHTTPRequest(String data) async {
+ String url = "$homeAssistantWebHost/api/notify.fcm-android";
+ Logger.d("[Sending] ==> $url");
+ http.Response response;
+ response = await http.post(
+ url,
+ headers: {
+ "authorization": "Bearer $_password",
+ "Content-Type": "application/json"
+ },
+ body: data
+ );
+ //var resData = json.decode(response.body);
+ Logger.d("[Received] <== ${response.statusCode}, ${response.body}");
+ }
}
class SendMessageQueue {
diff --git a/lib/main.dart b/lib/main.dart
index 460ffe3..2adaaaa 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -17,6 +17,7 @@ import 'package:progress_indicators/progress_indicators.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:flutter_custom_tabs/flutter_custom_tabs.dart';
+import 'package:firebase_messaging/firebase_messaging.dart';
part 'entity_class/const.dart';
part 'entity_class/entity.class.dart';
@@ -168,6 +169,7 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker
bool _accountMenuExpanded = false;
bool _useLovelaceUI;
int _previousViewCount;
+ final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
@override
void initState() {
@@ -186,6 +188,7 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker
});
}
});
+
_initialLoad();
}
@@ -254,6 +257,21 @@ class _MainPageState extends State with WidgetsBindingObserver, Ticker
_showErrorBottomBar(message: event.text, errorCode: event.errorCode);
});
}
+
+ /*_firebaseMessaging.getToken().then((String token) {
+ _homeAssistant.sendHTTPRequest('{"token": "$token"}');
+ });
+ _firebaseMessaging.configure(
+ onLaunch: (data) {
+ Logger.d("Notification [onLaunch]: $data");
+ },
+ onMessage: (data) {
+ Logger.d("Notification [onMessage]: $data");
+ },
+ onResume: (data) {
+ Logger.d("Notification [onResume]: $data");
+ }
+ );*/
}
_refreshData() async {
diff --git a/pubspec.lock b/pubspec.lock
index b25c2fe..d0eff9e 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -101,6 +101,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
+ firebase_messaging:
+ dependency: "direct main"
+ description:
+ name: firebase_messaging
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "4.0.0+1"
flutter:
dependency: "direct main"
description: flutter
@@ -244,6 +251,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
+ platform:
+ dependency: transitive
+ description:
+ name: platform
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "2.2.0"
progress_indicators:
dependency: "direct main"
description:
@@ -264,7 +278,7 @@ packages:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
- version: "0.5.1+1"
+ version: "0.5.1+2"
sky_engine:
dependency: transitive
description: flutter
diff --git a/pubspec.yaml b/pubspec.yaml
index 5390d6c..12c9303 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -20,6 +20,7 @@ dependencies:
flutter_markdown: any
flutter_svg: ^0.10.3
flutter_custom_tabs: ^0.6.0
+ firebase_messaging: ^4.0.0+1
dev_dependencies:
flutter_test: