mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 00:51:19 +00:00
wip notif
This commit is contained in:
parent
8924bc30e8
commit
11cca4d044
@ -6,6 +6,12 @@ if (localPropertiesFile.exists()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def keystoreProperties = new Properties()
|
||||||
|
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||||||
if (flutterRoot == null) {
|
if (flutterRoot == null) {
|
||||||
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||||||
@ -93,11 +99,20 @@ android {
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
signingConfigs {
|
||||||
|
release {
|
||||||
|
keyAlias keystoreProperties['keyAlias']
|
||||||
|
keyPassword keystoreProperties['keyPassword']
|
||||||
|
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
||||||
|
storePassword keystoreProperties['storePassword']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
// TODO: Add your own signing config for the release build.
|
// TODO: Add your own signing config for the release build.
|
||||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||||
signingConfig signingConfigs.debug
|
signingConfig signingConfigs.release
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
shrinkResources true
|
shrinkResources true
|
||||||
debuggable false
|
debuggable false
|
||||||
@ -118,6 +133,7 @@ dependencies {
|
|||||||
// When using the BoM, don't specify versions in Firebase dependencies
|
// When using the BoM, don't specify versions in Firebase dependencies
|
||||||
implementation 'com.google.firebase:firebase-analytics'
|
implementation 'com.google.firebase:firebase-analytics'
|
||||||
implementation 'com.google.firebase:firebase-messaging'
|
implementation 'com.google.firebase:firebase-messaging'
|
||||||
|
implementation 'com.google.firebase:firebase-messaging-directboot'
|
||||||
|
|
||||||
// Add the dependencies for any other desired Firebase products
|
// Add the dependencies for any other desired Firebase products
|
||||||
// https://firebase.google.com/docs/android/setup#available-libraries
|
// https://firebase.google.com/docs/android/setup#available-libraries
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
#Mon Jul 31 16:50:59 CEST 2023
|
#Tue Aug 01 16:05:42 CEST 2023
|
||||||
VERSION_BUILD=43
|
VERSION_BUILD=59
|
||||||
VERSION_MAJOR=1
|
VERSION_MAJOR=1
|
||||||
VERSION_MINOR=0
|
VERSION_MINOR=0
|
||||||
VERSION_PATCH=0
|
VERSION_PATCH=0
|
||||||
|
|||||||
@ -10,10 +10,6 @@ import 'package:myhomie_app/Models/homieContext.dart';
|
|||||||
import '../constants.dart';
|
import '../constants.dart';
|
||||||
|
|
||||||
class PushNotificationService {
|
class PushNotificationService {
|
||||||
//final FirebaseMessaging _fcm;
|
|
||||||
|
|
||||||
PushNotificationService(); //this._fcm
|
|
||||||
|
|
||||||
goToPage(Map<String, dynamic> message) {
|
goToPage(Map<String, dynamic> message) {
|
||||||
var notification = PushNotificationMessage(
|
var notification = PushNotificationMessage(
|
||||||
title: message['notification']['title'],
|
title: message['notification']['title'],
|
||||||
@ -36,12 +32,22 @@ class PushNotificationService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future initialise(HomieAppContext? homieAppContext, {required BuildContext context}) async {
|
Future initialise(HomieAppContext? homieAppContext, BuildContext context, [bool inMain = false]) async {
|
||||||
if (Platform.isIOS) {
|
if (Platform.isIOS) {
|
||||||
//_fcm.requestPermission(); // IosNotificationSettings
|
//_fcm.requestPermission(); // IosNotificationSettings
|
||||||
FirebaseMessaging.instance.requestPermission();
|
FirebaseMessaging.instance.requestPermission();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NotificationSettings settings = await FirebaseMessaging.instance.requestPermission(
|
||||||
|
alert: true,
|
||||||
|
announcement: false,
|
||||||
|
badge: true,
|
||||||
|
carPlay: false,
|
||||||
|
criticalAlert: false,
|
||||||
|
provisional: false,
|
||||||
|
sound: true,
|
||||||
|
);
|
||||||
|
|
||||||
//_fcm.subscribeToTopic("main");
|
//_fcm.subscribeToTopic("main");
|
||||||
|
|
||||||
FirebaseMessaging.instance.subscribeToTopic("main");
|
FirebaseMessaging.instance.subscribeToTopic("main");
|
||||||
@ -95,13 +101,17 @@ class PushNotificationService {
|
|||||||
);
|
);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
NotificationManager.handleNotificationMsg(notification, context);
|
if(!inMain) {
|
||||||
// show notification UI here
|
// show notification UI here
|
||||||
|
NotificationManager.handleNotificationMsg(notification, context);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) {
|
||||||
print('A new onMessageOpenedApp event was published!');
|
print('A new onMessageOpenedApp event was published!');
|
||||||
|
|
||||||
|
// TODO navigate somewhere in the app depending the coming message
|
||||||
|
|
||||||
/*Navigator.pushNamed(
|
/*Navigator.pushNamed(
|
||||||
context,
|
context,
|
||||||
'/message',
|
'/message',
|
||||||
@ -149,6 +159,7 @@ class DataNotification {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@pragma('vm:entry-point')
|
||||||
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
||||||
print("Handling a background message");
|
print("Handling a background message");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_app_bar.dart
|
|||||||
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_bottom_navigation_bar.dart';
|
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_bottom_navigation_bar.dart';
|
||||||
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_nav_item.dart';
|
import 'package:myhomie_app/Components/Custom_Navigation_Bar/custom_nav_item.dart';
|
||||||
import 'package:myhomie_app/Helpers/MQTTHelper.dart';
|
import 'package:myhomie_app/Helpers/MQTTHelper.dart';
|
||||||
|
import 'package:myhomie_app/Helpers/PushNotificationService.dart';
|
||||||
import 'package:myhomie_app/Screens/Debug/DebugPage.dart';
|
import 'package:myhomie_app/Screens/Debug/DebugPage.dart';
|
||||||
import 'package:myhomie_app/Screens/Main/Automations/automations.dart';
|
import 'package:myhomie_app/Screens/Main/Automations/automations.dart';
|
||||||
import 'package:myhomie_app/Screens/Main/Devices/devices.dart';
|
import 'package:myhomie_app/Screens/Main/Devices/devices.dart';
|
||||||
@ -50,6 +51,8 @@ class _MainPageState extends State<MainPage> {
|
|||||||
print("MQTT NOT INSTANTIATED");
|
print("MQTT NOT INSTANTIATED");
|
||||||
MQTTHelper.instance.connect(appContext);
|
MQTTHelper.instance.connect(appContext);
|
||||||
}
|
}
|
||||||
|
final pushNotificationService = PushNotificationService();
|
||||||
|
pushNotificationService.initialise(homieAppContext, context);
|
||||||
|
|
||||||
return ChangeNotifierProvider<Index>(
|
return ChangeNotifierProvider<Index>(
|
||||||
create: (_) => Index(0, appContext.getContext()),
|
create: (_) => Index(0, appContext.getContext()),
|
||||||
|
|||||||
@ -58,13 +58,14 @@ class _MyAppState extends State<MyApp> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final pushNotificationService = PushNotificationService();
|
/*final pushNotificationService = PushNotificationService();
|
||||||
pushNotificationService.initialise(widget.homieAppContext, context: context);
|
pushNotificationService.initialise(widget.homieAppContext, context, true);*/
|
||||||
|
|
||||||
return ChangeNotifierProvider<AppContext>(
|
return ChangeNotifierProvider<AppContext>(
|
||||||
create: (_) => AppContext(widget.homieAppContext),
|
create: (_) => AppContext(widget.homieAppContext),
|
||||||
child: MaterialApp(
|
child: MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'MyHomie App Demo',
|
title: 'MyHomie App',
|
||||||
initialRoute: widget.initialRoute,
|
initialRoute: widget.initialRoute,
|
||||||
/*supportedLocales: [
|
/*supportedLocales: [
|
||||||
const Locale('en', 'US'),
|
const Locale('en', 'US'),
|
||||||
@ -74,7 +75,7 @@ class _MyAppState extends State<MyApp> {
|
|||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
scaffoldBackgroundColor: kBackgroundColor,
|
scaffoldBackgroundColor: kBackgroundColor,
|
||||||
//fontFamily: "Vollkorn",
|
//fontFamily: "Vollkorn",
|
||||||
textTheme: TextTheme(bodyText1: TextStyle(color: kBodyTextColor)),
|
textTheme: TextTheme(bodyLarge: TextStyle(color: kBodyTextColor)),
|
||||||
visualDensity: VisualDensity.adaptivePlatformDensity,
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
||||||
),
|
),
|
||||||
routes: {
|
routes: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user