apptentive / apptentive-android

Apptentive Android SDK
http://www.apptentive.com
BSD 3-Clause "New" or "Revised" License
65 stars 64 forks source link

Unread message count listener not working #219

Closed arsonblock closed 3 years ago

arsonblock commented 3 years ago

On Android, the unread message count is not being returned with the listener in place. Is there still an issue with this functionality in the Android SDK?

Below is the code snippet used in my MainActivity.

private UnreadMessagesListener listener;

listener = new UnreadMessagesListener() {
            @Override
            public void onUnreadMessageCountChanged(int unreadMessages) {
            //Your code here
            if(unreadMessages > 0){
                bMessageCenter = true;
                mMessageCount = unreadMessages;
                if (mViewPager.getCurrentItem() != 4) {
                    showUnreadMessageDialog();
                }
                // Notify the user of unread messages in More Tab.
                GlobalBus.getBus().postSticky(new BusEvents.UnreadMessages(unreadMessages));
              }
            }
        };
        Apptentive.addUnreadMessagesListener(listener);
CaseyApptentive commented 3 years ago

Hi @arsonblock. I wanted to check in. Are you still experiencing issues with the message count listener?

arsonblock commented 3 years ago

Hi @arsonblock. I wanted to check in. Are you still experiencing issues with the message count listener?

Hello @CaseyApptentive, looks like the issue has been resolved, we are receiving the message count, however it is sometimes delayed which lead me to believe it wasn't working. Is this a known issue?

CaseyApptentive commented 3 years ago

Thanks for confirming, though sorry it wasn't working quite as expected. Did it take a few minutes to appear?

I'd have to dig to figure out the exact mechanism for when the listener would work. If I recall, it should run at specific points, or at least every few minutes. Which can make testing a bit more difficult, but has minimal impact on customers in the wild and reduces traffic.

Let me know. I believe this is working as expected, though I can make this more clear in our docs.

Thanks again.

arsonblock commented 3 years ago

@CaseyApptentive yes, it would take a few minutes to trigger, if that’s the intended behavior, we can live with that.

In some instances it wouldn’t trigger the listener until I entered the message center again, then the unread message count would be received, strange behavior in that case for sure and concerned me the most.

Thanks again!

CaseyApptentive commented 3 years ago

Yes, I believe this is correct. Don't hold me to the exact numbers, but I believe the intervals to check are roughly 5 or so minutes when the app is backgrounded, but we check every time Message Center is launched.

Let me know if you need anything else. Thanks!