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

isSupported returns false positive #8129

Open
ptahchiev opened this issue Apr 5, 2024 · 10 comments
Open

isSupported returns false positive #8129

ptahchiev opened this issue Apr 5, 2024 · 10 comments

Comments

@ptahchiev
Copy link

ptahchiev commented Apr 5, 2024

Operating System

iOS v 17.3

Browser Version

Safari

Firebase SDK Version

10.10.0

Firebase SDK Product:

Messaging

Describe your project's tooling

React app with webpack

Describe the problem

I'm trying to develop push notifications with FCM. Here's part of the code:

import { getMessaging, onMessage, getToken, isSupported } from "firebase/messaging";
....
try {
  if (isSupported) {
    console.log('is supported');
      // Retrieve Firebase Messaging object
      messaging = getMessaging(app);
  }
} catch (e) {
  console.error(e)
}

As you can see I'm using isSupported. However in the log I can see that is supported is printed and then an error is thrown: This browser does not support the APIs required to use the Firebase SDK.
Screenshot from 2024-04-05 16-29-32

If I comment the snippet then no error is thrown and nothing is logged in the console.

Steps and code to reproduce issue

Just call isSupported on iOS and you will see it returns true

@ptahchiev ptahchiev added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Apr 5, 2024
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Apr 5, 2024
@jbalidiong
Copy link
Contributor

Hi @ptahchiev, thanks for bringing this to our attention. I tried replicating, but I wasn't able to reproduce the error. If I can replicate the issue, I can have a better look into it. Please share a minimal, but complete sample of a project that I can run locally.

@DellaBitta
Copy link
Contributor

Just checking to ensure that your code is correct.

Are you invoking if(isSupported()) or just checking if it's defined if(isSupported). Looks like the latter is in the test case above.

Thanks!

@ptahchiev
Copy link
Author

Here's a reproducible site:
https://ptahchiev.github.io/test-firebase/
with repository:
https://github.com/ptahchiev/test-firebase/
and result:
image

@jbalidiong
Copy link
Contributor

Thanks for the minimal repro, @ptahchiev. I was able to replicate the behavior. Let me check what we can do for this issue or bring someone here that can provide more context about it. I’ll update this thread if I have any information to share.

@hsubox76
Copy link
Contributor

I'm not able to get an iOS emulator running at the moment to repro this, but I think the problem is that isSupported() is an async function, so you would have to do if (await isSupported()). In your sample code, the value of isSupported() isn't actually true, it's a promise, which is truthy, which always causes your if to pass. If you logged the value of isSupported() instead of the string "isSupported() is true", this would show up.

Can I ask what documentation guide or tutorial you used for adding isSupported()? I want to make sure we didn't make a mistake and we add await if needed.

@SteveKennedy
Copy link

Just dropping in to say I have same issue. I am using await isSupported(). And get same exact experience as OP. My only difference is I am using 10.11.0.

@hsubox76
Copy link
Contributor

Can you provide a repro like the original poster did?

@google-oss-bot
Copy link
Contributor

Hey @ptahchiev. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

@zwu52
Copy link
Member

zwu52 commented Apr 29, 2024

Is your manifest configured correctly with { "display": "standalone" } // or {"display": "fullscreen"}? The config appears to be an requirement according to https://firebase.blog/posts/2023/08/fcm-for-safari/

@google-oss-bot
Copy link
Contributor

Hey @ptahchiev. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

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

No branches or pull requests

7 participants