firebase-js-sdk
firebase-js-sdk copied to clipboard
isSupported returns false positive
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
.
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
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.
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!
Here's a reproducible site:
https://ptahchiev.github.io/test-firebase/
with repository:
https://github.com/ptahchiev/test-firebase/
and result:
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.
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.
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.
Can you provide a repro like the original poster did?
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!
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/
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!
Since there haven't been any recent updates here, I am going to close this issue.
@ptahchiev if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.