mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-11 13:47:38 +01:00
Rename existing reminder channel on start
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
957ddc7ddc
commit
0982565fdc
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user