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-messaging.js broken on iOS Safari 11.1.2 #1260

Closed
ecreatures opened this issue Sep 28, 2018 · 9 comments
Closed

firebase-messaging.js broken on iOS Safari 11.1.2 #1260

ecreatures opened this issue Sep 28, 2018 · 9 comments

Comments

@ecreatures
Copy link

We're using firebase messaging with version 5.5.4 in a vue project and Safari 11.1.2 is broken : a blank page is displayed.

The error raised in the console is :
"FirebaseError: Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser)."

Same error on Safari IOS with iOS 11 and 12. Before integrating FDirebase messaging in our project all was working fine. We're currently using other Firebase services in our project and they work fine.

@google-oss-bot
Copy link
Contributor

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@ee92
Copy link

ee92 commented Oct 1, 2018

Just importing firebase/messaging seems to cause this issue for me as well.. Is there a way to do it conditionally based on browser?

update - actually importing didnt cause issue, actually trying to use messaging sdk did.

solution

// importing it
import 'firebase/messaging'
let messaging = null
if (firebase.messaging.isSupported()) {
   messaging = firebase.messaging()
   messaging.usePublicVapidKey("{yourkey")
}
export { messaging }

// actually using it
import { messaging } from 'firebase.js'
FCM() {
   if (!messaging) return
   messaging.requestPermission()
   .then(() => {
      ...
   }
}

@ecreatures
Copy link
Author

In theory Firebase messaging is supposed to manage the Safari not able to receive notification case, but in real life it does not. To avoid the Safari blank page, you need to trigger the user agent/browser condition in your code.
Here's a snippet (vue.js) of what we didi each time we needed firebase messaging

if(Notification){
            // Notifications supported! Yay!

            // Init messaging
            const messaging = firebase.messaging()  
			messaging.usePublicVapidKey(<YOUR-PUBLIC-KEY-HER>)
			
			// Do whatever you need with messaging
	}

@piuskamil
Copy link

or just:

try {
      this.messaging = messaging();
    } catch (err) {
      console.log(err);
    }

@mmermerkaya
Copy link
Contributor

Messaging does not work on Safari, because Safari does not support Push API. You can check the compatibility table here.

I'd suggest using .isSupported() instead of the other solutions, as @ee92 mentioned.

if (firebase.messaging.isSupported())
	const messaging = firebase.messaging();
}

See the documentation for details on .isSupported().

@nitesh663
Copy link

Thanks a lot @mmermerkaya ...it's really helpful....
I am getting exception while browsing in edge/internet-explorer ...now it's working great.

@wcjord
Copy link

wcjord commented Feb 12, 2019

Was this resolved? I'm getting the same error in Safari 12.0.2

muldoon2007 added a commit to RadicalxChange/hoverboard that referenced this issue Feb 15, 2019
@andreszs
Copy link

Can someone explain why the Safari 12 web push notifications implementation cannot be added to FCM? We know it requires the annoying certificates from the 100-USD-a-year Apple Developers portal, but for those who have them, there should be an updated guide on how to implement it, rather than simply waiting until Apple decides to align with the rest of the browsers (if it ever does).

If an experienced developer created a PR to support Safari 12, would this PR be approved and merged eventually to the FCM JS API?

@mmermerkaya
Copy link
Contributor

Unfortunately this requires more than just changes to this SDK. We also need to support APNs for web in the FCM backend.

The feature request is being tracked here: #1423. There's no information that I can share yet, but that does not mean that we're not working on it.

@firebase firebase locked and limited conversation to collaborators Oct 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants