Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge count on iOS app icon #438

Open
timabbott opened this issue Mar 17, 2017 · 41 comments
Open

Badge count on iOS app icon #438

timabbott opened this issue Mar 17, 2017 · 41 comments
Labels

Comments

@timabbott
Copy link
Member

timabbott commented Mar 17, 2017

As part of our effort to display unread message counts, we should make sure to include an unread messages bad on the app icon.

[edited following discussion below]

We want to show a badge on the app's icon on the iOS home screen when the user has notifications for messages they haven't read.

@timabbott timabbott added this to the M6 milestone Mar 17, 2017
@divs4debu
Copy link
Collaborator

divs4debu commented Apr 23, 2017

@timabbott While searching for this i found this stackoverflow link - http://stackoverflow.com/questions/17565307/how-to-display-count-of-notifications-in-app-launcher-icon
It says we could it using widgets as vanilla android doesnot allow you to draw on app icon. What are your thoughts?

@timabbott
Copy link
Member Author

There seem to be a number of apps that do this on Android without requiring the user to install a widget; it's probably worth doing a bit more research into options for doing this.

@borisyankov
Copy link
Contributor

@divs4debu Note the date of the question on StackOverflow. Things move fast on mobile and 4 years is definitely an eternity.

I actually have not seen an app on stock Android doing the badges (while it is a standard feature on iOS). Maybe it is very dependent on what launcher the user has?!?

In any way, there are prerequisites to be implemented before this is even possible. We need to add mechanism for the app to pull messages while not running.

@divs4debu
Copy link
Collaborator

divs4debu commented Apr 23, 2017

@borisyankov the mechanism for app to pull messages while not running could be -

@timabbott can you mention some apps that does that i would like to do specific research on app that does that.

@jainkuniya
Copy link
Member

facebook app is a good example.

@borisyankov
Copy link
Contributor

@vishwesh3 what is Facebook an example for? Not sure I follow.

@divs4debu ideally the solution will be both for Android and iOS.

Related issue:
#408

@jainkuniya
Copy link
Member

@vishwesh3 what is Facebook an example for? Not sure I follow.
Showing counts on icon

@divs4debu
Copy link
Collaborator

@vishwesh3 i just downloaded the facebook app but it doesnt show any badge and i have 11 notification 2 messages on facebook . This might be due to some mobile provide this function and some not .

@divs4debu
Copy link
Collaborator

divs4debu commented Apr 23, 2017

@borisyankov Using headless.js would help only if app is not focus but wont help when app is closed . We can wait for 0.44 update. it might have some component for that

@jainkuniya
Copy link
Member

ok. This might depend on phone UI or launcher.

@jainkuniya
Copy link
Member

yup! it depends on mobile launcher
In my default launcher it is showing
89a473b1-de93-4387-b5fd-d6f66c205825
but not showing in google now launcher

@bhaskarmurthy
Copy link

Looks like Android O (API 26) adds notification badge support natively - https://developer.android.com/reference/android/app/NotificationChannel.html#setShowBadge

@zulipbot
Copy link
Member

Hello @zulip/server-notifications members, this issue was labeled with the "area: notifications" label, so you may want to check it out!

@gnprice
Copy link
Member

gnprice commented Jun 6, 2018

For cross-reference: the server-side issue for this is zulip/zulip#7459 .

@sai713
Copy link

sai713 commented Jul 16, 2018

my app doesn't providing any notifications but even though it is showing some notification count badge on app icon. please help me out

@AmitJoki
Copy link

Is this issue still open? I'd like to look at it.

@borisyankov
Copy link
Contributor

@AmitJoki yeah, no one is currently working on that.
Feel free to explore the issue and let us know if any back-end changes are required to make this work.

@timabbott
Copy link
Member Author

@borisyankov I believe this is actually in progress, and mostly complete; see zulip/zulip#7459.

@zbenjamin
Copy link
Member

I haven't looked at the code in zulip/zulip#7459 to see what it currently does, but I was thinking that Zulip might actually want to display something other than raw unread counts. On iOS, the badge for the Messages shows the number of unread messages across all conversations, while the badge for the Facebook Messenger app shows the number of conversations that have unread messages in them. At first I found the FB Messenger app behavior weird, but I've now come to believe that it feels less overwhelming to have a lower badge count. I think Zulip should do something similar to FB Messenger and aggregate unread messages for the badge count [*].

I suspect the correct grouping for the counts are: each distinct PM conversation (individual and group), muted stream/topic pairs with @-mentions (assuming Zulip alerts on those to begin with), and each stream/topic pair with unread messages (or possibly only each stream with unread messages).

  • Actually, perhaps Zulip should do this elsewhere, as well. I've gotten the feedback from housemates that they find the number of unread messages that Zulip tells them they have overwhelming.

@borisyankov
Copy link
Contributor

These are good points. We should be conservative with the 'unread counts' and badges in general. People love heir 'Inbox zero' and if a user does not have anything urgently needing their attention, we should probably not be showing any badge.

It is worth noting that the badges on Android did not even exist prior to Android 8, and were kinda 'emulated' by the launchers to be something like 'unread notifications' which may or may not be equal to the unread count we would be showing.

There is some short reading here:
https://developer.android.com/training/notify-user/badges

@borisyankov
Copy link
Contributor

To summarize my thoughts:

  • we should try to have consistent unread count between the web favicon, the iOS app's badge and the Android launcher badges (latter might be impossible due to differences in meaning between launchers and platform versions)
  • we should try to keep a low unread count, only including high priority messages or even an aggregate by narrow

@gnprice
Copy link
Member

gnprice commented Sep 25, 2019

(See also zulip/zulip#10271 .)

@chrisbobbe chrisbobbe added the experimental UI/UX To be user-tested in experimental build label Feb 24, 2020
@chrisbobbe
Copy link
Contributor

(I just closed #676 as covered by this issue; it has a link to https://developer.android.com/preview/features/notification-badges.html.)

@chrisbobbe
Copy link
Contributor

Bumping the priority.

@timabbott said:

We just got another user question about when Zulip will support iOS unread badges on the app (like we have on Android); this is starting to feel like LaTeX as a feature we've had 10+ people explicitly ask for.

@gnprice
Copy link
Member

gnprice commented Aug 12, 2020

Update:

The implementation of this feature lives on the server side. We have a draft implementation, but it remains disabled because of a bug; see chat discussion.

We had another report of this missing feature today in chat.

@gnprice gnprice changed the title Add unread messages badge on app icon Badge count on iOS app icon Aug 12, 2020
@gnprice gnprice added the a-iOS label Aug 12, 2020
@gnprice gnprice removed this from the Next milestone Aug 12, 2020
@gnprice
Copy link
Member

gnprice commented Aug 12, 2020

I've edited this issue to be specifically about iOS, because the implementation will be pretty much separate for iOS and Android.

On Android, badge counts don't even exist on stock Android, at least in versions from the last few years. There are badge dots, but with no numbers -- it's just there or not -- and I believe it's controlled automatically by whether a notification exists.

Badge counts do exist in some vendors' Android launchers, notably Samsung. We have some code in the app (and have for a long time now) that is supposed to maintain these, using a third-party library with this purpose.

I don't actually know for sure whether that code, for those proprietary vendors' launchers, works -- the APIs unfortunately seem to be vendor-specific, so the implementation of that library in turn goes and does something for each of a long list of different vendors, as applicable: Samsung, Huawei, Sony, Vivo, Asus, … 14 of them in total. That in turn makes it infeasible to test. If for someone it's not working, a separate bug report would be appropriate.

@chrisbobbe
Copy link
Contributor

Since this issue has the labels a-IOS and a-notifications, I'm marking it as blocked by #4115, so we only have to implement a solution once. The PR #4163 is currently open for that issue.

@chrisbobbe chrisbobbe added the blocked on other work To come back to after another related PR, or some other task. label Nov 10, 2020
@gnprice gnprice removed the blocked on other work To come back to after another related PR, or some other task. label Jun 18, 2021
@gnprice
Copy link
Member

gnprice commented Jun 18, 2021

#4163 is merged!

@gnprice
Copy link
Member

gnprice commented Jun 18, 2021

So the issue is back in this status:

The implementation of this feature lives on the server side. We have a draft implementation, but it remains disabled because of a bug; see chat discussion.

That bug is #4182. The bug isn't live now, because the feature is disabled (we have the server just always send 0 for the badge count.) But I expect that if we were to just re-enable the current implementation, that bug would reappear with it, so that we'll need to do some debugging.

@timabbott
Copy link
Member Author

If it'd be useful to re-enable the feature on chat.zulip.org only (for example), that's certainly something we can do.

@gnprice
Copy link
Member

gnprice commented Feb 14, 2022

We've had another request for this in chat, and one more back in November:

@chrisbobbe
Copy link
Contributor

We've had another request on CZO.

@laz-
Copy link

laz- commented Aug 2, 2022

Can confirm that this bug lives on... There is still no unread count on the ios icon

@rkurchin
Copy link

Recent (experimental) convert from Slack here...would also really love this feature to work!

@HaroldvanGarderen
Copy link

This seems so basic to all iOS apps that I’m a bit surprised by the lack if progress in 5!! years.

@uselpa
Copy link

uselpa commented Oct 23, 2022

Currently evaluating Zulip. Absence of decent support for iOS is a show stopper for every company.

@v3ss0n
Copy link

v3ss0n commented Jan 2, 2023

This seems so basic to all iOS apps that I’m a bit surprised by the lack if progress in 5!! years.

Could be easy to contribute, why don't you give it a try.

@GitSparTV
Copy link

I wish I was an iOS developer to contribute this, the only thing I can say is: such a missing feature :(

@ugenk
Copy link

ugenk commented Nov 29, 2023

Most requested feature in zulip, on my mind. Unread counter works perfect on MacOS, but does not work at all on iOS.

@jefferypalmer
Copy link

jefferypalmer commented Feb 22, 2024

Posting this patch here to enable the iOS badge notifications that our team likes to see, even though there is a pending bug on the iOS side that clears the badge when the app is opened/foregrounded, but the server does still set the badge count properly on the next push notification.

diff --git a/push_notifications.py b/home/zulip/deployments/current/zerver/lib/push_notifications.py
index 7023639..9c08d8f 100644
--- a/push_notifications.py
+++ b/home/zulip/deployments/current/zerver/lib/push_notifications.py
@@ -1042,10 +1042,14 @@ def get_apns_alert_subtitle(
 def get_apns_badge_count(
     user_profile: UserProfile, read_messages_ids: Optional[Sequence[int]] = []
 ) -> int:
-    # NOTE: We have temporarily set get_apns_badge_count to always
-    # return 0 until we can debug a likely mobile app side issue with
-    # handling notifications while the app is open.
-    return 0
+    # The iOS mobile app does not keep a correct badge count after the app is opened,
+    # but will show the correct value when the push notfication is received. Issue
+    # number https://github.com/zulip/zulip-mobile/issues/438
+    return (
+        UserMessage.objects.filter(user_profile=user_profile)
+        .extra(where=[UserMessage.where_unread()])
+        .count()
+    )


 def get_apns_badge_count_future(

ios_push_notification_patch.patch

@gnprice
Copy link
Member

gnprice commented Mar 12, 2024

Thanks @jefferypalmer for posting that patch. One refinement you might like (which I expect we'd do when we eventually return to this issue) would be to add UserMessage.where_active_push_notification() to that "where" clause — that should filter it down to only the messages that caused a notification in the first place. (For example, by default you get notifications for DMs and @-mentions but not for all the other messages sent to streams you're subscribed to, so the latter messages show up in a where_unread query but not where_active_push_notification.)

As an update for everyone interested in this issue: this app is now in maintenance mode as we're focused on building the new Zulip mobile app in Flutter, and so this is an issue I don't expect us to go back and fix for the legacy app. But once that migration is done, this is definitely an issue I expect us to come back to and fix there — it's been a longstanding gap which we regularly hear bothers people. It's in the new app's tracker as zulip/zulip-flutter#153 .

This is also among the areas where Flutter will put us in a much better position to fix things than we've been with React Native in the existing app. In particular, to get this right it's likely we'll need some code handling the notification blobs from the server to also consult the data we've previously stored locally from the server (and your other servers where applicable) — and, at #5589, that's the very point where I decided we'd had enough with React Native and it was time to seriously consider a move to Flutter. (That issue is focused on the Android case but I expect the story is similar with iOS and Swift.) And indeed Flutter supports that situation quite smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests