Skip to content

Commit 785df22

Browse files
committed
notif android: Keep the notification icon from being resource-shrunk away
Details in the new comment and in the issue thread. Fixes: #528
1 parent 03c8bbe commit 785df22

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

android/app/src/main/res/raw/keep.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- This file is necessary for notifications to work in release builds.
3+
4+
The issue is that the package:flutter_local_notifications API has us
5+
identify which icon we want to use via a string name, in Dart code,
6+
and that's invisible to the resource shrinker:
7+
https://developer.android.com/build/shrink-code#keep-resources
8+
If the icon isn't named in this file, it gets removed in release builds
9+
(more precisely, replaced with a 0-byte file, which is invalid for its
10+
image format). The system then discards notifications that try to use
11+
the invalid icon file:
12+
https://github.com/zulip/zulip-flutter/issues/528
13+
-->
14+
<resources xmlns:tools="http://schemas.android.com/tools"
15+
tools:keep="@drawable/zulip_notification"
16+
/>

lib/notifications.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ class NotificationDisplayManager {
322322
'(Zulip internal error)', // TODO never implicitly create channel: https://github.com/MaikuB/flutter_local_notifications/issues/2135
323323
tag: conversationKey,
324324
color: kZulipBrandColor,
325-
icon: 'zulip_notification', // TODO vary for debug
325+
// TODO vary notification icon for debug
326+
icon: 'zulip_notification', // This name must appear in keep.xml too: https://github.com/zulip/zulip-flutter/issues/528
326327
// TODO(#128) inbox-style
327328

328329
// TODO plugin sets PendingIntent.FLAG_UPDATE_CURRENT; is that OK?

0 commit comments

Comments
 (0)