mirror of
https://bitbucket.org/myhomie/myhomie_app.git
synced 2025-12-06 00:51:19 +00:00
46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:myhomie_app/Components/custom_dialog.dart';
|
|
import 'package:myhomie_app/Helpers/PushNotificationService.dart';
|
|
|
|
class NotificationManager {
|
|
|
|
static BuildContext? _context;
|
|
static String defaultButtonLabel = "Merci !";
|
|
|
|
static init({required BuildContext context}) {
|
|
_context = context;
|
|
}
|
|
|
|
static handleDataMsg(Map<String, dynamic> data){
|
|
}
|
|
|
|
static handleNotificationMsg(PushNotificationMessage message) {
|
|
//We can add showDialog key in future
|
|
/*if (data.containsKey('showDialog')) {
|
|
// Handle data message with dialog
|
|
_showDialog(data);
|
|
}*/
|
|
_showDialog(message: message);
|
|
}
|
|
|
|
|
|
static _showDialog({required PushNotificationMessage message}) {
|
|
var buttonLabel = message.data.labelButton == null ? defaultButtonLabel : message.data.labelButton;
|
|
|
|
showDialog(
|
|
context: _context!,
|
|
builder: (BuildContext context) => CustomDialog(
|
|
title: message.title,
|
|
description: message.body,
|
|
buttonText: buttonLabel!,
|
|
onPress: () => {
|
|
/*if (message.data.type != null) {
|
|
PageSwitcher(message.data.type)
|
|
}*/
|
|
}
|
|
),
|
|
);
|
|
}
|
|
|
|
} |