Skip to content

Commit e2cf339

Browse files
committed
notif [nfc]: Add Android-only asserts in NotificationDisplayManager methods
NotificationDisplayManager's public methods only get invoked on Android, and their implementations basically assume the platform is Android. So, add these asserts, to make that assumption clearer and to fail early if we accidentally call one of these on iOS. When we eventually take more hands-on control of notifications on iOS, we might either adapt this class to support iOS too, or make a new class for iOS and make this one's name and interface clearer that it's Android-only. Discussion: https://chat.zulip.org/#narrow/channel/243-mobile-team/topic/NotificationDisplayManager.20Android-only/near/2099196
1 parent b6ca7b2 commit e2cf339

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/notifications/display.dart

+5
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,12 @@ class NotificationChannelManager {
217217
/// Service for managing the notifications shown to the user.
218218
class NotificationDisplayManager {
219219
static Future<void> init() async {
220+
assert(defaultTargetPlatform == TargetPlatform.android);
220221
await NotificationChannelManager.ensureChannel();
221222
}
222223

223224
static void onFcmMessage(FcmMessage data, Map<String, dynamic> dataJson) {
225+
assert(defaultTargetPlatform == TargetPlatform.android);
224226
switch (data) {
225227
case MessageFcmMessage(): _onMessageFcmMessage(data, dataJson);
226228
case RemoveFcmMessage(): _onRemoveFcmMessage(data);
@@ -490,6 +492,8 @@ class NotificationDisplayManager {
490492
required BuildContext context,
491493
required Uri url,
492494
}) {
495+
assert(defaultTargetPlatform == TargetPlatform.android);
496+
493497
final globalStore = GlobalStoreWidget.of(context);
494498

495499
assert(debugLog('got notif: url: $url'));
@@ -518,6 +522,7 @@ class NotificationDisplayManager {
518522
/// generated with [NotificationOpenPayload.buildUrl] while creating
519523
/// the notification.
520524
static Future<void> navigateForNotification(Uri url) async {
525+
assert(defaultTargetPlatform == TargetPlatform.android);
521526
assert(debugLog('opened notif: url: $url'));
522527

523528
NavigatorState navigator = await ZulipApp.navigator;

0 commit comments

Comments
 (0)