humhub / fcm-push

Enables your users to receive push notifications from your network.
4 stars 5 forks source link

Push Service for the Android mobile app not working anymore #30

Open marc-farre opened 11 months ago

marc-farre commented 11 months ago

It was working before (I cannot tell which version, but with 2.0.0-beta), but on version 2.0.0-beta.9 (and perhaps before), the Push Service is not working on the Android mobile app version 1.0.75 and Android 11.

Step to reproduce the problem:

With https://community.humhub.com/ you are still into the Humhub instance. With another Humhub instance, the app displays the Humhub instance URL field. Once entered, you are already logged in (the app kept the cookies).

Other symptom: push notifications works with the app for https://community.humhub.com/ but not for another Humhub instance.

The tested instance:

But I don't know if that's normal, each time I refresh the page on https://push.humhub.com/ the API Keys are different.

luke- commented 10 months ago

@marc-farre Just tested different scenarios and it works well on my side. Can you please test it again with latest app version?

marc-farre commented 10 months ago

@luke- tested again with app version 1.0.76 and I still have the same problem (with https://community.humhub.com all is OK).

Is it normal that, each time I refresh the page on https://push.humhub.com/, the API Keys are different?

Is there a debugger I can look at to check what's happening?

luke- commented 10 months ago

@marc-farre Yes, it's normal when the API Keys change. (JWT Token). What is the URL of the sending instance? d***.cuzy.app?

marc-farre commented 10 months ago

Thanks @luke- for your help. Indeed, I forgot this hidden debug page. Very usefull!

But wow, something has changed... App notifications work again! And when I quit the app and open it again, I don't see the Humhub instance URL form, I'm directly on the home page.

Strangely, I still have "App Detection - Current Request: NO App Request Detected" in the debug page. But it works well.

I didn't do anything to make it work, tests are done exactly the same way, and the app has not been reinstalled. It's like if the "Test notification on the debug page" made it work!

I've configured another Humhub instance and tested, it works well too. So I'll close this issue and reopen it if I see something else wrong.

luke- commented 10 months ago

@marc-farre The message App Detection - Current Request: NO App Request Detected should only appear, when the debug page is accessed via a normal Browser.

If you access the Debug page via the mobile app, this message should not appear.

marc-farre commented 9 months ago

I reopen the issue because I'm still having randomly the issue.

I have the green "App Detection - Current Request: Is App Request". Everything seams to be well configured and push notifications are well received on the browser.

But on the mobile app, sometimes it works, sometimes not. Tested with 3 different instances. I've also removed the mobile app data and reinstalled the app.

Maybe I should move this issue to the mobile app repository as the Firebase push service works well for the browser?

luke- commented 9 months ago

@marc-farre Hmm, we can check whether the notification arrives at our push service. Can you send me a registered push device ID (debug page, first 6 characters) and URL of a missing notification as a private message. Then I'll check whether it was forwarded.

marc-farre commented 9 months ago

@luke- Thank for your investigation proposal. Now I understand better what's happening:

I've tested on 4 different instances. All of them are on the latest stable versions (core and push module) and on the same server. All is green in Prerequisites and I've done everything described here: https://community.humhub.com/s/installation-and-setup/wiki/Mobile+app+%26+Push+notifications I have the green "App Detection - Current Request: Is App Request" and browser push notifications works well on all 4 instances.

But:

On instance 1, I had 3 registered push devices. I've deleted them, came back on the instance in the mobile app, and a new one is created. Then mobile app notifications worded again. Each time I change instance in the mobile app, a registered push device ID is deleted (when I'm in another instance) and recreated (when I come back to it). So this is perfect, it works well now. But I don't know why I had 3 registered push devices and why I had to manually delete them.

On instances 2, 3 and 4, I nether get any registered push device. Even if I "Send registerFcmDevice message": Screenshot_20231108_185222_com humhub app

luke- commented 9 months ago

@marc-farre

On instance 1, I had 3 registered push devices. I've deleted them, came back on the instance in the mobile app, and a new one is created. Then mobile app notifications worded again. Each time I change instance in the mobile app, a registered push device ID is deleted (when I'm in another instance) and recreated (when I come back to it). So this is perfect, it works well now. But I don't know why I had 3 registered push devices and why I had to manually delete them.

Please note that a browser also counts as an extra push device. Could this explain the 3 devices?

On instances 2, 3 and 4, I nether get any registered push device. Even if I "Send registerFcmDevice message": Screenshot_20231108_185222_com humhub app

So you never received push messages from these instances? Not even on the browser?

marc-farre commented 9 months ago

Please note that a browser also counts as an extra push device. Could this explain the 3 devices?

I see. I've done some tests, and it appears that:

So you never received push messages from these instances? Not even on the browser?

I receive notifications on the desktop computer browser: image

But I don't receive notification neither on the mobile app, nor on a browser of the mobile phone.

In summary:

luke- commented 9 months ago

@marc-farre There may be a mix-up here between normal browser notifications and browser push notifications.

Browser Notifications

Only when HumHub tab is open. Work without "push", it's triggered by the HumHub live component, which per default uses polling.

image

Browser Push Notifications

I only receive browser push notifications when the browser tab is not active, e.g. even when it is closed. But here registered DeviceID is necessary in the Push Notification Debug Page.

image

When I click "Reset Permission", the browser asks me again, whether notifications should be sent.

Following message should appear in the console:

image

And a new new "Registered FireBase Device" should appear on the Debug Page.

Note: This works only, when Firebase is configured manually. Our "Push Service" doesn't send Browser Push notifications.

Mobile App Push

When a user logs in via the mobile app for the first time, a new device should be displayed on the mobile app debug page. When logging out, this device should be removed again.

Note: The Browser Push Service must be configured.

If it's not working, maybe Notifications are blocked in the Android App Settings?

marc-farre commented 9 months ago

@luke- Thanks very much for your time and the explanations. I've took the opportunity to fill up this doc page: https://github.com/humhub/documentation/pull/90/files

So now I understand what was the problem with the "Desktop Browser". It was due to Brave which disable by default Google Services for push messaging: https://stackoverflow.com/a/69624651

Today, notifications on mobile app works on the 3 other instances (I did no change...) and I can see them on the Registered FireBase Devices... I still don't understand why it works intermittently. Next time I have the problem again, I'll try to understand. Maybe something to due with https://github.com/humhub/app/issues/139

FYI (I don't know if it's a problem):

luke- commented 9 months ago

@marc-farre [...]

Today, notifications on mobile app works on the 3 other instances (I did no change...) and I can see them on the Registered FireBase Devices... I still don't understand why it works intermittently. Next time I have the problem again, I'll try to understand. Maybe something to due with humhub/app#139

Let me know, when the problem occur again.

FYI (I don't know if it's a problem):

  • On the browser, if I reset permission and block notifications, or if I logout, the Registered FireBase Device is not deleted.
  • With the mobile app, it's well deleted after logging out

I've created a issue here: https://github.com/humhub/fcm-push/issues/32

marc-farre commented 9 months ago

Let me know, when the problem occur again.

Test today:

  1. Open Humhub app: I'm still well logged in to Humhub instance (this instance uses an SSO)
  2. Trigger "HumHub Update" notification
  3. No notification received
  4. Logout / Login
  5. A new FireBase Device has been registered
  6. Trigger "HumHub Update" notification
  7. Notification received

So for this test, I've lost the FireBase Device registration after a while (I logged in a few days ago). I'll do more tests in the days to come.

marc-farre commented 9 months ago

@luke- This issue is I think the major problem we have to use the mobile app. I've asked people to test the app, and I'm often facing these problems:

  1. I need to manually delete all FireBase Device registration devices, logout and login again in the app
  2. The devices nether gets registered (even with the above procedure)
  3. The FireBase Device registration is lost after a while

When I have multiple registered devices such as image Is there a way to know which one is the mobile app?

luke- commented 8 months ago

@marc-farre Tokens with the sender id 21392898126 should belong to the HumHub Proxy Service (Mobile App).

Do your tests also show that the push notifications stop working after a while?

marc-farre commented 8 months ago

@luke- Thanks.

push notifications stop working after a while

I don't have the problem anymore. Now, "Registered FireBase Devices" seams to be persistant, but I'm doing too few tests to answer well (based on 2 Humhub instances since one week).

If it was possible to display in the "Registered FireBase Devices" list which one is for the mobile app it could help understanding what's going on, because it's quite difficult to understand what's causing the problems with these "Registered FireBase Devices". I cannot found a way to reproduce them.