diff --git a/app/lib/services/notification_backend_io.dart b/app/lib/services/notification_backend_io.dart index d2d166c..653b51c 100644 --- a/app/lib/services/notification_backend_io.dart +++ b/app/lib/services/notification_backend_io.dart @@ -24,6 +24,20 @@ class LocalNotificationsBackend implements NotificationBackend { android: AndroidInitializationSettings('@mipmap/ic_launcher'), ); await plugin.initialize(settings: settings); + + // Re-create the channel so Android renames it if an install still shows + // the old "Meal reminders" label. + await plugin + .resolvePlatformSpecificImplementation< + AndroidFlutterLocalNotificationsPlugin + >() + ?.createNotificationChannel( + const AndroidNotificationChannel( + _channelId, + _channelName, + importance: Importance.high, + ), + ); } /// Requests Android 13+'s runtime `POST_NOTIFICATIONS` permission. diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 508dcc5..704c02d 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -2,7 +2,7 @@ name: diet_guard_app description: "Companion phone app for diet_guard: log meals on the go." publish_to: 'none' -version: 1.0.150+1 +version: 1.0.151+1 environment: sdk: ^3.12.2 diff --git a/app/test/services/notification_service_test.dart b/app/test/services/notification_service_test.dart index 90d2c85..5618652 100644 --- a/app/test/services/notification_service_test.dart +++ b/app/test/services/notification_service_test.dart @@ -34,6 +34,23 @@ void main() { expect(log.where((c) => c.method == 'initialize'), hasLength(1)); }); + test('init renames the reminder channel to the app name', () async { + final log = installFakeAndroidNotifications(); + NotificationService.resetForTesting( + backend: LocalNotificationsBackend(FlutterLocalNotificationsPlugin()), + ); + + await NotificationService.init(); + + final createCall = log.firstWhere( + (c) => c.method == 'createNotificationChannel', + orElse: () => throw StateError('no createNotificationChannel call logged'), + ); + final args = createCall.arguments as Map; + expect(args['id'], reminderChannelId); + expect(args['name'], 'DietGuard'); + }); + test('requestPermission delegates to the Android implementation', () async { installFakeAndroidNotifications(); NotificationService.resetForTesting(