Skip to content

Commit

Permalink
Merge pull request #691 from hpi-studyu/fix/notifications
Browse files Browse the repository at this point in the history
Fix/notifications
  • Loading branch information
ibrahimozkn authored Oct 2, 2024
2 parents 44e3bb2 + 0be9d0c commit 457e4aa
Show file tree
Hide file tree
Showing 15 changed files with 204 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.24.2"
"flutter": "3.24.3"
}
26 changes: 13 additions & 13 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.971.0)
aws-sdk-core (3.203.0)
aws-partitions (1.981.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.89.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.160.0)
aws-sdk-core (~> 3, >= 3.203.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.9.1)
aws-sigv4 (1.10.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand All @@ -39,7 +39,7 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.111.0)
faraday (1.10.3)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -65,10 +65,10 @@ GEM
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.222.0)
fastlane (2.223.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -152,7 +152,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.2)
jwt (2.8.2)
jwt (2.9.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand All @@ -171,7 +171,7 @@ GEM
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.3.7)
rexml (3.3.8)
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -193,7 +193,7 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
Expand Down
42 changes: 20 additions & 22 deletions app/ios/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.956.0)
aws-sdk-core (3.201.1)
aws-partitions (1.981.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
aws-sigv4 (~> 1.8)
aws-sigv4 (~> 1.9)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.88.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.156.0)
aws-sdk-core (~> 3, >= 3.201.0)
aws-sdk-s3 (1.166.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.8.0)
aws-sigv4 (1.10.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
Expand All @@ -39,7 +39,7 @@ GEM
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.111.0)
faraday (1.10.3)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
Expand All @@ -60,15 +60,15 @@ GEM
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.3.1)
fastlane (2.221.1)
fastlane (2.223.1)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
Expand Down Expand Up @@ -126,7 +126,7 @@ GEM
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.7.0)
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
Expand All @@ -147,12 +147,12 @@ GEM
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.6)
http-cookie (1.0.7)
domain_name (~> 0.5)
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.2)
jwt (2.8.2)
jwt (2.9.1)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand All @@ -164,15 +164,14 @@ GEM
optparse (0.5.0)
os (1.1.4)
plist (3.7.1)
public_suffix (6.0.0)
public_suffix (6.0.1)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.2.9)
strscan
rexml (3.3.8)
rouge (2.0.7)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
Expand All @@ -185,7 +184,6 @@ GEM
simctl (1.6.10)
CFPropertyList
naturally
strscan (3.1.0)
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
Expand All @@ -195,15 +193,15 @@ GEM
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.5.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.24.0)
xcodeproj (1.25.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
rexml (>= 3.3.2, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand Down
10 changes: 5 additions & 5 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ PODS:
- record_darwin (1.0.0):
- Flutter
- FlutterMacOS
- Sentry/HybridSDK (8.35.1)
- sentry_flutter (8.8.0):
- Sentry/HybridSDK (8.36.0)
- sentry_flutter (8.9.0):
- Flutter
- FlutterMacOS
- Sentry/HybridSDK (= 8.35.1)
- Sentry/HybridSDK (= 8.36.0)
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
Expand Down Expand Up @@ -130,8 +130,8 @@ SPEC CHECKSUMS:
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
record_darwin: df0a677188e5fed18472550298e675f19ddaffbe
Sentry: 1fe34e9c2cbba1e347623610d26db121dcb569f1
sentry_flutter: a39c2a2d67d5e5b9cb0b94a4985c76dd5b3fc737
Sentry: f8374b5415bc38dfb5645941b3ae31230fbeae57
sentry_flutter: 0eb93e5279eb41e2392212afe1ccd2fecb4f8cbe
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec
url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
Expand Down
35 changes: 21 additions & 14 deletions app/lib/util/debug_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
Expand Down Expand Up @@ -58,15 +57,16 @@ class DebugScreen {
),
child: const Text('Send debug information via email'),
),
ElevatedButton(
onPressed: () {
testNotification(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.secondary,
if (context.read<AppState>().studyNotifications != null)
ElevatedButton(
onPressed: () {
testNotification(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.secondary,
),
child: const Text('Receive test notification'),
),
child: const Text('Receive test notification'),
),
ElevatedButton(
onPressed: () {
showDialog(
Expand Down Expand Up @@ -182,11 +182,18 @@ class DebugScreen {
}

static Future<void> testNotification(BuildContext context) async {
// Notifications not supported on web
if (kIsWeb) return;
final appState = context.read<AppState>();
final studyNotifications = appState.studyNotifications;
if (studyNotifications == null) return;
final studyNotifications = context.read<AppState>().studyNotifications;
if (studyNotifications == null) {
Navigator.of(context).pop();
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text(
'Notifications are not initialized yet. Please start a study and open this through the about section.',
),
),
);
return;
}
await studyNotifications.flutterLocalNotificationsPlugin.show(
/*******************/
99,
Expand Down
6 changes: 2 additions & 4 deletions app/lib/util/schedule_notifications.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,14 @@ Future<void>? cancelNotifications(BuildContext context) async {
final list1 = await notificationsPlugin?.pendingNotificationRequests() ?? [];
final list2 =
await FlutterLocalNotificationsPlugin().pendingNotificationRequests();
final listres = list1.isEmpty && list2.isEmpty;
assert(listres);
StudyNotifications.scheduledNotificationsDebug = 'cleared';

if (context.mounted) context.read<AppState>().studyNotifications = null;
if (StudyNotifications.debug) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
'Notifications cancelled and pending notifications are empty: $listres',
'Notifications cancelled and pending notifications are empty: ${list1.isEmpty && list2.isEmpty}',
),
),
);
Expand Down
Loading

0 comments on commit 457e4aa

Please sign in to comment.