This commit is contained in:
estevez-dev 2019-03-18 23:37:45 +02:00
parent 5140840d3a
commit d70ba0a55a
10 changed files with 103 additions and 4 deletions

View File

@ -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'

View File

@ -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"
}

View File

@ -30,6 +30,10 @@
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
<intent-filter>
<action android:name="FLUTTER_NOTIFICATION_CLICK" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>

View File

@ -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'
}
}

View File

@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx2g
org.gradle.daemon=true
org.gradle.caching=true
android.useAndroidX=true
android.enableJetifier=false
android.enableJetifier=true

View File

@ -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

View File

@ -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 {

View File

@ -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<MainPage> 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<MainPage> with WidgetsBindingObserver, Ticker
});
}
});
_initialLoad();
}
@ -254,6 +257,21 @@ class _MainPageState extends State<MainPage> 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 {

View File

@ -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

View File

@ -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: