zulip / zulip-mobile

Zulip mobile apps for Android and iOS.
https://zulip.com/apps/
Apache License 2.0
1.29k stars 652 forks source link

Badge count on iOS app icon #438

Open timabbott opened 7 years ago

timabbott commented 7 years ago

~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.

divs4debu commented 7 years ago

@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 commented 7 years ago

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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

facebook app is a good example.

borisyankov commented 7 years ago

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

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

Related issue: https://github.com/zulip/zulip-mobile/issues/408

jainkuniya commented 7 years ago

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

divs4debu commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

ok. This might depend on phone UI or launcher.

jainkuniya commented 7 years ago

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 commented 6 years ago

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

zulipbot commented 6 years ago

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

gnprice commented 6 years ago

For cross-reference: the server-side issue for this is https://github.com/zulip/zulip/issues/7459 .

sai713 commented 6 years ago

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 commented 6 years ago

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

borisyankov commented 6 years ago

@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 commented 6 years ago

@borisyankov I believe this is actually in progress, and mostly complete; see https://github.com/zulip/zulip/issues/7459.

zbenjamin commented 6 years ago

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).

borisyankov commented 6 years ago

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 commented 6 years ago

To summarize my thoughts:

gnprice commented 5 years ago

(See also zulip/zulip#10271 .)

chrisbobbe commented 4 years ago

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

chrisbobbe commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Since this issue has the labels a-IOS and a-notifications, I'm marking it as blocked by https://github.com/zulip/zulip-mobile/issues/4115, so we only have to implement a solution once. The PR https://github.com/zulip/zulip-mobile/pull/4163 is currently open for that issue.

gnprice commented 3 years ago

4163 is merged!

gnprice commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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

chrisbobbe commented 2 years ago

We've had another request on CZO.

laz- commented 2 years ago

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

rkurchin commented 2 years ago

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

HaroldvanGarderen commented 2 years ago

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

uselpa commented 2 years ago

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

v3ss0n commented 1 year ago

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 commented 1 year ago

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

ugenk commented 11 months ago

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

jefferypalmer commented 8 months ago

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 commented 8 months ago

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 https://github.com/zulip/zulip-flutter/issues/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.