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

Firebase Legacy API remove #46

Open
luke- opened this issue Aug 9, 2024 · 5 comments
Open

Firebase Legacy API remove #46

luke- opened this issue Aug 9, 2024 · 5 comments

Comments

@luke-
Copy link
Contributor

luke- commented Aug 9, 2024

Remove Legacy API

@ArchBlood
Copy link
Contributor

@luke- removing FcmLegacy class along with any calls for it then running composer update fixes the issue, but do note that ext-sodium is required, so the requirements.php should also check to make sure that this is checked.

@luke- luke- assigned yurabakhtin and unassigned yurabakhtin Aug 9, 2024
@l-salewski
Copy link

Hey,
I tried to configure this FCM addon for a HumHub instance and was never able to register tokens: No registered Firebase Tokens for the current user! (on Firefox or Chrome on Mac or Android). After some digging in the browser console I found this response to the subscribe call:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=[//www.google.com/](view-source:https://www.google.com/)><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/fcm/connect/subscribe</code> was not found on this server.  <ins>That’s all we know.</ins>

(the message is cut of like that, this is not a copy paste error)

Additionally I found a 501 error for the POST request to https://fcm.googleapis.com/fcm/connect/subscribe and this error ERROR - humhub.modules.firebase: An error occurred while retrieving token. FirebaseError: Messaging: A problem occured while subscribing the user to FCM: Operation is not implemented, or supported, or enabled. (messaging/token-subscribe-failed)..

A bit of googling reveals that this is probably due to the Cloud Messaging API Legacy being deprecated more than a year ago and being disabled about three months ago:

If you are an existing user of the legacy HTTP or XMPP APIs (deprecated on 6/20/2023), you must migrate to the latest Firebase Cloud Messaging API (HTTP v1) by 6/20/2024. Learn more

As I created my Firebase projects more recently, I have to use the V1 version. Is it possible that this addon still only uses the deprecated and disabled API version that is incompatible with the V1 firebase version?

@ArchBlood
Copy link
Contributor

Hey, I tried to configure this FCM addon for a HumHub instance and was never able to register tokens: No registered Firebase Tokens for the current user! (on Firefox or Chrome on Mac or Android). After some digging in the browser console I found this response to the subscribe call:

<!DOCTYPE html>
<html lang=en>
  <meta charset=utf-8>
  <meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
  <title>Error 404 (Not Found)!!1</title>
  <style>
    *{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
  </style>
  <a href=[//www.google.com/](view-source:https://www.google.com/)><span id=logo aria-label=Google></span></a>
  <p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/fcm/connect/subscribe</code> was not found on this server.  <ins>That’s all we know.</ins>

(the message is cut of like that, this is not a copy paste error)

Additionally I found a 501 error for the POST request to https://fcm.googleapis.com/fcm/connect/subscribe and this error ERROR - humhub.modules.firebase: An error occurred while retrieving token. FirebaseError: Messaging: A problem occured while subscribing the user to FCM: Operation is not implemented, or supported, or enabled. (messaging/token-subscribe-failed)..

A bit of googling reveals that this is probably due to the Cloud Messaging API Legacy being deprecated more than a year ago and being disabled about three months ago:

If you are an existing user of the legacy HTTP or XMPP APIs (deprecated on 6/20/2023), you must migrate to the latest Firebase Cloud Messaging API (HTTP v1) by 6/20/2024. Learn more

As I created my Firebase projects more recently, I have to use the V1 version. Is it possible that this addon still only uses the deprecated and disabled API version that is incompatible with the V1 firebase version?

As I stated in the above comment (i.e. #46 (comment)) the module currently works with both the old API and the new one, the only issue here is by default the old API is used over the new API which is why this issue was opened. 👍🏻

@l-salewski
Copy link

l-salewski commented Sep 12, 2024

Thanks for the swift reply! I am not very familiar with this projects source code nor with PHP, so apologies for this maybe naive question: Is what you are proposing in #46 (comment) possible through configuration in the installed module or would I need to touch the source code?
Edit: After digging through the source code it looks like FCM should be the default, but maybe it falls back to FCMLegacy because the FCM init fails (unfortunately there is no logging for this). Could this be related to the Custom CSP and if yes, can that be set in the administration UI?

@ArchBlood
Copy link
Contributor

Thanks for the swift reply! I am not very familiar with this projects source code nor with PHP, so apologies for this maybe naive question: Is what you are proposing in #46 (comment) possible through configuration in the installed module or would I need to touch the source code? Edit: After digging through the source code it looks like FCM should be the default, but maybe it falls back to FCMLegacy because the FCM init fails (unfortunately there is no logging for this). Could this be related to the Custom CSP and if yes, can that be set in the administration UI?

Currently as stated, the discussion is on-going for removing the legacy API from the module itself, i don't recommend touching the source code if you're not familiar with PHP or Yii2 and recommend waiting till a new version is released with the dropped support.

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

No branches or pull requests

4 participants