Skip to content

Commit

Permalink
web version fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaCoduriV committed Sep 26, 2021
1 parent 502b550 commit 54186c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "heig_front",
"request": "launch",
"type": "dart"
},
{
"name": "heig_front (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
}
]
}
13 changes: 6 additions & 7 deletions lib/controllers/notifications_manager.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io' show Platform;

import 'package:awesome_notifications/awesome_notifications.dart';
import 'package:flutter/foundation.dart' show kIsWeb;
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';

Expand All @@ -9,13 +8,13 @@ class NotificationsManager {
var box = Hive.box('heig');

NotificationsManager() {
if (Platform.isAndroid || Platform.isIOS) {
if (!kIsWeb) {
_notificationsId = box.get('notification_id', defaultValue: 0);
}
}

Future<void> initialize() async {
if (Platform.isAndroid || Platform.isIOS) {
if (!kIsWeb) {
await AwesomeNotifications().initialize(
null,
[
Expand Down Expand Up @@ -47,7 +46,7 @@ class NotificationsManager {

Future<int> registerNotificationHoraire(
String title, String body, DateTime date) async {
if (Platform.isAndroid || Platform.isIOS) {
if (!kIsWeb) {
AwesomeNotifications().createNotification(
schedule: NotificationCalendar.fromDate(date: date),
content: NotificationContent(
Expand All @@ -63,7 +62,7 @@ class NotificationsManager {
}

Future<void> listenNotification() async {
if (Platform.isAndroid || Platform.isIOS) {
if (!kIsWeb) {
AwesomeNotifications().actionStream.listen((receivedNotification) {
switch (receivedNotification.payload?['page']) {
case 'todo':
Expand All @@ -79,7 +78,7 @@ class NotificationsManager {

Future<int> registerNotificationTodo(
String title, String body, DateTime date, int id) async {
if (Platform.isAndroid || Platform.isIOS) {
if (!kIsWeb) {
AwesomeNotifications().createNotification(
schedule:
DateTime.now().isAfter(date.subtract(const Duration(days: 1)))
Expand Down

0 comments on commit 54186c2

Please sign in to comment.