ChildMindInstitute / mindlogger-app

MindLogger (React Native) data collection app
Other
15 stars 6 forks source link

⚠️⏰ App icon's badge number doesn't increment; `PushNotificationIOS.setApplicationIconBadgeNumber(1)` #330

Closed shnizzedy closed 4 years ago

shnizzedy commented 4 years ago

A few things about this line:

https://github.com/ChildMindInstitute/mindlogger-app/blob/c9b26b5a01649c5f3c8e8b7bb32a11532d744ad9/app/services/pushNotifications.js#L39

shnizzedy commented 4 years ago

related https://github.com/ChildMindInstitute/mindlogger-app/issues/307

InheritxSolution commented 4 years ago

If we want to manage the badge count dynamically then the best way to achieve this functionality is the push notification so the badge directly comes up with the push notification and badge display dynamically.

Please check this link https://stackoverflow.com/a/5962607.

Managing this count is typical process with the local notification because for that we need to track those count locally and manage with every schedule notification and at the time of resetting those count we need to make copy of the already scheduled notifications and at the time of resetting the data we need to re-schedule the notification again.

Let me know if you want more explanation for the same.

shnizzedy commented 4 years ago
binarybottle commented 4 years ago

From this morning's standup meeting, I understand that incrementing a badge number is difficult with local notifications. We will set this issue aside and tackle it later.

binarybottle commented 4 years ago

Just to be clear, this issue is about badges/indicators on the app icon, not about numbered indicators on the applets, correct?

IMG-0016

shnizzedy commented 4 years ago

A badge, as discussed in #306, is circled in this screenshot: badge on MindLogger

binarybottle commented 4 years ago

@Eden2016:

So what I’ve figured out about this issue is… that the badge count can be increased only from the server-sent notifications (ex. Firebase notif. service). And we can increase the badge number manually only when the app is open.

shnizzedy commented 4 years ago

I think Object.keys(overdue).length is the value we want in the badge:

https://github.com/ChildMindInstitute/mindlogger-app/blob/5fd1f3c6f2116c42a747bbd6d9721ec50218e96a/app/components/ActivityList/sortActivities.js#L58

https://github.com/ChildMindInstitute/mindlogger-app/blob/e739b490216b0f2fcca6c54d30430ea108a7e14f/app/components/ActivityList/index.js#L24

WorldImpex commented 4 years ago

Badge shows with notification and disappears after push notification is selected