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

navigator.serviceWorker not available on iOS in-app browsers. #7535

Open
diegofer25 opened this issue Aug 8, 2023 · 0 comments
Open

navigator.serviceWorker not available on iOS in-app browsers. #7535

diegofer25 opened this issue Aug 8, 2023 · 0 comments

Comments

@diegofer25
Copy link

Operating System

iOS 16.0

Browser Version

in app browser, i can't see the version, browser that open when click a link on instagram for example.

Firebase SDK Version

^9.22.2

Firebase SDK Product:

Messaging

Describe your project's tooling

Vue 3 app with Vite and Quasar in PWA mode

Describe the problem

The issue

When I import the firebase/messaging it executes the method registerMessagingInWindow() globally in the packages/messaging/src/index.ts#45 and it's a problem because the navigator.serviceWorker don't exists in the in-app browser of iOS braking all the page.

Workaround solution:

I'm importing dynamically the firebase/messaging like

export async function getToken (opt: { vapidKey: string }) {
  const messagingModule = await import('firebase/messaging');
  const messaging = messagingModule.getMessaging(app);

  return messagingModule.getToken(messaging, { vapidKey: opt.vapidKey });
}

And I'm checking if the browser is in-app browser with:

const ua = navigator.userAgent || navigator.vendor || window.opera || '';
  const inAppBrowser = /instagram|fbav|twitter|GSA|tiktok/i.test(ua);

  if (inAppBrowser) {
    return;
  }

if it's an in-app browser i don't want to handle messaging cuz they don't should do it.

Steps and code to reproduce issue

Just create any project with Webpack or Vite and import firebase/messaging in any place of your code statically and try to open this page in the iOS 16 in-app browser like Instagram or Google.

@diegofer25 diegofer25 added new A new issue that hasn't be categoirzed as question, bug or feature request question labels Aug 8, 2023
@jbalidiong jbalidiong added needs-attention and removed new A new issue that hasn't be categoirzed as question, bug or feature request labels Aug 8, 2023
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

3 participants