firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

firebase.messaging() causes Nuxt.js PWA to lock up on IOS

Open limjix opened this issue 6 years ago • 3 comments

I've just developed a NUXTJS app as a PWA and it works fine on my android and laptop machines. But it doesn't work on IOS devices. Ive packaged this up and deployed this to firebase hosting. This is what I see on IOS devices and I am not sure how to debug it. It's just an orange loading icon which goes on forever. The app was tested on IPhones and Ipads using both chrome browser and safari. https://i.stack.imgur.com/vk5zT.jpg

Then, I found the offender, in my firebase init.js file

import * as firebase from "firebase/app";
import "firebase/auth";
import "firebase/firestore";
import "firebase/database";
import "firebase/storage";
import "firebase/messaging";

var config = {
  //settings
};

!firebase.apps.length ? firebase.initializeApp(config) : "";
export const GoogleProvider = new firebase.auth.GoogleAuthProvider();
export const auth = firebase.auth();
export const persistencetype = firebase.auth.Auth.Persistence.LOCAL;

export const firestoreDB = firebase.firestore().collection("").doc("");
export const firestore = firebase.firestore;
export const storage = firebase.app().storage("");

export const messaging = firebase.messaging(); // THIS IS THE OFFENDING LINE

export default firebase;

For some reason, the export const messaging = firebase.messaging() doesn't work on IOS Perhaps someone from the Firebase team can shed some light on this? I am using version "firebase": "^7.14.3",

    "@firebase/messaging": {
      "version": "0.6.15",
      "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.6.15.tgz",
      "integrity": "sha512-WswV3JtxAgqc0LPQtIBdMWJdMhVZu7gKF6MO5ETIpNaLZZ0QayYNu5+G9btoZz218HB/gvUp2NFX43OWAsqdZw==",
      "requires": {
        "@firebase/component": "0.1.11",
        "@firebase/installations": "0.4.9",
        "@firebase/messaging-types": "0.4.4",
        "@firebase/util": "0.2.46",
        "idb": "3.0.2",
        "tslib": "1.11.1"
      }
    },

I replicated the problem in this repo https://github.com/limjix/firebasecloudmessagingbug

limjix avatar Jul 09 '20 09:07 limjix

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.

google-oss-bot avatar Jul 09 '20 09:07 google-oss-bot

https://stackoverflow.com/questions/49745221/can-we-run-firebase-realtime-listening-on-ios-serviceworker/49803408#49803408

malizade1991 avatar Jul 11 '20 19:07 malizade1991

As @malizade1991 pointed out, web push notification is still not supported on iOS as of today (7/13/2020). You should detect the environment and not initialize firebase messaging in mobile safari.

Feiyang1 avatar Jul 13 '20 23:07 Feiyang1