notification push wip

This commit is contained in:
Thomas Fransolet 2023-07-31 16:52:19 +02:00
parent 8a269dc8d4
commit 8924bc30e8
7 changed files with 87 additions and 65 deletions

View File

@ -1,5 +1,5 @@
#Fri Jul 28 17:03:08 CEST 2023 #Mon Jul 31 16:50:59 CEST 2023
VERSION_BUILD=32 VERSION_BUILD=43
VERSION_MAJOR=1 VERSION_MAJOR=1
VERSION_MINOR=0 VERSION_MINOR=0
VERSION_PATCH=0 VERSION_PATCH=0

View File

@ -1,12 +1,12 @@
buildscript { buildscript {
ext.kotlin_version = '1.6.10' ext.kotlin_version = '1.7.10'
repositories { repositories {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:7.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.15' classpath 'com.google.gms:google-services:4.3.15'
} }
@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app') project.evaluationDependsOn(':app')
} }
task clean(type: Delete) { tasks.register("clean", Delete) {
delete rootProject.buildDir delete rootProject.buildDir
} }

View File

@ -15,21 +15,21 @@ class NotificationManager {
static handleDataMsg(Map<String, dynamic> data){ static handleDataMsg(Map<String, dynamic> data){
} }
static handleNotificationMsg(PushNotificationMessage message) { static handleNotificationMsg(PushNotificationMessage message, BuildContext context) {
//We can add showDialog key in future //We can add showDialog key in future
/*if (data.containsKey('showDialog')) { /*if (data.containsKey('showDialog')) {
// Handle data message with dialog // Handle data message with dialog
_showDialog(data); _showDialog(data);
}*/ }*/
_showDialog(message: message); _showDialog(message: message, context: context);
} }
static _showDialog({required PushNotificationMessage message}) { static _showDialog({required PushNotificationMessage message, required BuildContext context}) {
var buttonLabel = message.data.labelButton == null ? defaultButtonLabel : message.data.labelButton; var buttonLabel = message.data.labelButton == null ? defaultButtonLabel : message.data.labelButton;
showDialog( showDialog(
context: _context!, context: context,
builder: (BuildContext context) => CustomDialog( builder: (BuildContext context) => CustomDialog(
title: message.title, title: message.title,
description: message.body, description: message.body,

View File

@ -65,10 +65,16 @@ class PushNotificationService {
}, },
); );
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessage.listen((data) { FirebaseMessaging.onMessage.listen((data) {
var notification; var notification;
print("onMessage: $data"); print("onMessage: $data");
print(data); print(data.from);
print(data.category);
print(data.contentAvailable);
print(data.notification?.title);
print(data.notification?.body);
if (Platform.isAndroid) { if (Platform.isAndroid) {
notification = PushNotificationMessage( notification = PushNotificationMessage(
@ -76,7 +82,7 @@ class PushNotificationService {
body: data.notification!.body!, body: data.notification!.body!,
data: DataNotification( data: DataNotification(
//labelButton: message['data']['labelButton'], //labelButton: message['data']['labelButton'],
type: data.messageType!) type: data.messageType)
); );
} }
/*if (Platform.isIOS) { /*if (Platform.isIOS) {
@ -89,7 +95,7 @@ class PushNotificationService {
); );
}*/ }*/
NotificationManager.handleNotificationMsg(notification); NotificationManager.handleNotificationMsg(notification, context);
// show notification UI here // show notification UI here
}); });
@ -134,15 +140,19 @@ class PushNotificationMessage {
class DataNotification { class DataNotification {
final String? collapseKey; final String? collapseKey;
final String type; final String? type;
final String? labelButton; final String? labelButton;
DataNotification({ DataNotification({
this.collapseKey, this.collapseKey,
required this.type, this.type,
this.labelButton this.labelButton
}); });
} }
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print("Handling a background message");
}
/*PageSwitcher(String type) { /*PageSwitcher(String type) {
switch(type) { switch(type) {
case "home": case "home":

View File

@ -10,6 +10,7 @@ import 'Screens/Main/MainPage.dart';
import 'Screens/Login/login_screen.dart'; import 'Screens/Login/login_screen.dart';
import 'app_context.dart'; import 'app_context.dart';
import 'constants.dart'; import 'constants.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@ -37,6 +38,8 @@ void main() async {
homieAppContext: localContext!, homieAppContext: localContext!,
); );
await Firebase.initializeApp();
runApp(myApp); runApp(myApp);
} }

View File

@ -37,10 +37,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.11.0"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
@ -125,10 +125,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.3.0"
checked_yaml: checked_yaml:
dependency: transitive dependency: transitive
description: description:
@ -157,10 +157,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.2"
convert: convert:
dependency: transitive dependency: transitive
description: description:
@ -173,10 +173,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: crypto name: crypto
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.3"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -226,7 +226,7 @@ packages:
source: hosted source: hosted
version: "6.1.4" version: "6.1.4"
firebase_core: firebase_core:
dependency: transitive dependency: "direct main"
description: description:
name: firebase_core name: firebase_core
sha256: "2e9324f719e90200dc7d3c4f5d2abc26052f9f2b995d3b6626c47a0dfe1c8192" sha256: "2e9324f719e90200dc7d3c4f5d2abc26052f9f2b995d3b6626c47a0dfe1c8192"
@ -298,10 +298,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: flutter_svg name: flutter_svg
sha256: "12006889e2987c549c4c1ec1a5ba4ec4b24d34d2469ee5f9476c926dcecff266" sha256: "8c5d68a82add3ca76d792f058b186a0599414f279f00ece4830b9b231b570338"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.4" version: "2.0.7"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -412,26 +412,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.13" version: "0.12.16"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.5.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.9.1"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -444,10 +444,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: mqtt_client name: mqtt_client
sha256: "53186347058f0eb84b6b5e0591f8442cb05183abb787afc4d95a3c7a494068df" sha256: "873c124f6485c17b5ca085047880068f3c5acc9db54317995d752a3253f95a72"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "9.8.0" version: "10.0.0"
mycore_api: mycore_api:
dependency: "direct main" dependency: "direct main"
description: description:
@ -467,26 +467,26 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: openapi_generator name: openapi_generator
sha256: "2c9cf35d91a26330f09ec4a2370f07c5e3040921bd3f33751ba36ac4d2346dc0" sha256: "9efeccb3920683e71cc3927478eb6c2e97bf23500bff50a98185b755ff33a083"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.0" version: "4.11.1"
openapi_generator_annotations: openapi_generator_annotations:
dependency: "direct main" dependency: "direct main"
description: description:
name: openapi_generator_annotations name: openapi_generator_annotations
sha256: "1745b86b57943c5a09647c37dd909da61060ad65a0d3d3e48bef58f9c1eebb32" sha256: "6a46858a623076758198e94a94bdc797b1ba5260ab8544a61c809922014de44c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.0" version: "4.11.0"
openapi_generator_cli: openapi_generator_cli:
dependency: "direct main" dependency: "direct main"
description: description:
name: openapi_generator_cli name: openapi_generator_cli
sha256: "5d558ea599202dc487f829193b0ba0f28a0e7ad559e819a611b2146ef20c77f5" sha256: c737a64e1ef01b382dab7b43bc04b04c4642b19bb12e9f2609dd9f7827c6016b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.0" version: "4.11.0"
package_config: package_config:
dependency: transitive dependency: transitive
description: description:
@ -499,10 +499,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.3"
path_parsing: path_parsing:
dependency: transitive dependency: transitive
description: description:
@ -515,10 +515,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: petitparser name: petitparser
sha256: "49392a45ced973e8d94a85fdb21293fbb40ba805fc49f2965101ae748a3683b4" sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.1.0" version: "5.4.0"
plugin_platform_interface: plugin_platform_interface:
dependency: transitive dependency: transitive
description: description:
@ -600,10 +600,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.10.0"
sqflite: sqflite:
dependency: "direct main" dependency: "direct main"
description: description:
@ -672,10 +672,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.16" version: "0.6.0"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -688,10 +688,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
sha256: "26f87ade979c47a150c9eaab93ccd2bebe70a27dc0b4b29517f2904f04eb11a5" sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.1" version: "1.3.2"
uuid: uuid:
dependency: "direct main" dependency: "direct main"
description: description:
@ -704,26 +704,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_graphics name: vector_graphics
sha256: "4cf8e60dbe4d3a693d37dff11255a172594c0793da542183cbfe7fe978ae4aaa" sha256: "670f6e07aca990b4a2bcdc08a784193c4ccdd1932620244c3a86bb72a0eac67f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.4" version: "1.1.7"
vector_graphics_codec: vector_graphics_codec:
dependency: transitive dependency: transitive
description: description:
name: vector_graphics_codec name: vector_graphics_codec
sha256: "278ad5f816f58b1967396d1f78ced470e3e58c9fe4b27010102c0a595c764468" sha256: "7451721781d967db9933b63f5733b1c4533022c0ba373a01bdd79d1a5457f69f"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.4" version: "1.1.7"
vector_graphics_compiler: vector_graphics_compiler:
dependency: transitive dependency: transitive
description: description:
name: vector_graphics_compiler name: vector_graphics_compiler
sha256: "0bf61ad56e6fd6688a2865d3ceaea396bc6a0a90ea0d7ad5049b1b76c09d6163" sha256: "80a13c613c8bde758b1464a1755a7b3a8f2b6cec61fbf0f5a53c94c30f03ba2e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.1.4" version: "1.1.7"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -740,6 +740,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.0.2" version: "1.0.2"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
web_socket_channel: web_socket_channel:
dependency: transitive dependency: transitive
description: description:
@ -752,10 +760,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: xml name: xml
sha256: "979ee37d622dec6365e2efa4d906c37470995871fe9ae080d967e192d88286b5" sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "6.2.2" version: "6.3.0"
yaml: yaml:
dependency: transitive dependency: transitive
description: description:
@ -765,5 +773,5 @@ packages:
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.19.0 <3.0.0" dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=3.7.0-0" flutter: ">=3.7.0-0"

View File

@ -18,21 +18,21 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+2 version: 1.0.0+2
environment: environment:
sdk: ">=2.17.0 <3.0.0" sdk: ">=2.19.4 <3.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
fluttertoast: fluttertoast:
openapi_generator_cli: ^4.0.0 openapi_generator_cli: ^4.11.0
openapi_generator: ^4.0.0 openapi_generator: ^4.11.1
openapi_generator_annotations: ^4.0.0 openapi_generator_annotations: ^4.11.0
sqflite: sqflite:
provider: ^6.0.5 provider: ^6.0.5
enum_to_string: ^2.0.1 enum_to_string: ^2.0.1
flutter_svg: ^2.0.4 flutter_svg: ^2.0.7
mqtt_client: ^9.8.0 mqtt_client: ^10.0.0
rxdart: ^0.27.7 rxdart: ^0.27.7
flare_flutter: ^3.0.2 flare_flutter: ^3.0.2
uuid: ^3.0.7 uuid: ^3.0.7
@ -40,8 +40,9 @@ dependencies:
path: mycore_api path: mycore_api
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.5
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
firebase_core: ^2.15.0
firebase_messaging: ^14.6.5 firebase_messaging: ^14.6.5
dev_dependencies: dev_dependencies: