Closed kamizx786 closed 1 month ago
I'm unfamiliar with React Native WebViews but this is the check that runs that leads to that error if any of these conditions fail:
typeof window !== 'undefined' &&
isIndexedDBAvailable() &&
areCookiesEnabled() &&
'serviceWorker' in navigator &&
'PushManager' in window &&
'Notification' in window &&
'fetch' in window &&
ServiceWorkerRegistration.prototype.hasOwnProperty('showNotification') &&
PushSubscription.prototype.hasOwnProperty('getKey')
Those are the APIs that the messaging SDK requires, and it seems one of those fails in your React Native WebView environment. You can try to pinpoint which one by running those checks one-by-one yourself in your own code. If you can identify which one, you may be able to polyfill it, but some of them may not be possible to polyfill or work around.
Let us know if you identify which condition(s) fail and if you think it's a false positive somehow. Otherwise it would seem FCM is not supported in this environment.
So I Try to Test and got to know in React native web view These conditions are failing
'serviceWorker' in navigator && 'PushManager' in window && 'Notification' in window &&
If these APIs do not exist in this environment, the FCM web SDK won't be able to work and is unsupported in that environment. If you want to use FCM in React Native, you'll have to find another method such as React Native Firebase.
Operating System
Android IOS
Browser Version
Chrome,Safari
Firebase SDK Version
10.12.3
Firebase SDK Product:
Messaging
Describe your project's tooling
Nextjs
Describe the problem
I'm working on a project where I have a React web app that is embedded within a React Native WebView. I'm using Firebase Cloud Messaging (FCM) for handling notifications. The web app works fine when deployed on a secure domain (https://), but when I open the same web app in a WebView in my React Native app, I encounter the following error:
This browser doesn't support the API requested to use by Firebase SDK
This code works perfectly in the web browser but fails when the web app is loaded within the WebView of my React Native app.
Steps and code to reproduce issue