Skip to content

fetch is not a function #75

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

Closed
sharpcoder77 opened this issue Jun 22, 2017 · 5 comments
Closed

fetch is not a function #75

sharpcoder77 opened this issue Jun 22, 2017 · 5 comments
Assignees

Comments

@sharpcoder77
Copy link

Describe your environment

  • Operating System version: Ubuntu 14.04.02
  • Firebase SDK version: 4.1.3
  • Firebase Product: messaging

Describe the problem

Firebase messaging doesn't work with latest npm package. It throws:

TypeError: fetch is not a function
    at WindowController.manifestCheck_ (window-controller.js?:149)
    at WindowController.getToken (window-controller.js?:125)

Exact line in code is here

Steps to reproduce:

Install latest firebase package from npm. Follow tutorial given here.

Relevant Code:

      firebase.initializeApp(opts);
      const messaging = firebase.messaging();
      messaging.requestPermission()
        .then(function() {
          console.log('Notification permission granted.');
          return messaging.getToken()
            .then((currentToken) => {
              if (currentToken) {
                console.log("Token is: " + currentToken)
              } else {
                // you don't have permission to show notifications
                // detect whether they are blocked or not, then show your custom UI
              }
            })
            .catch((err) => {
              console.log("Error to get token is: " + err);
              // retrieving token failed, analyze the error
            });
        })
        .catch(function(err) {
          console.log('Unable to get permission to notify.', err);
        });
@google-oss-bot
Copy link
Contributor

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

@jsayol
Copy link
Contributor

jsayol commented Jun 22, 2017

It seems like there should be a check for the Fetch API here.

Either that, or use a polyfill like this one maybe?

@jshcrowthe
Copy link
Contributor

@skstronghold On which browser are you seeing this behavior? Messaging only supports browsers that support service worker (see https://firebase.google.com/docs/cloud-messaging/js/client) so I'd be curious if this isn't a browser issue.

That said, @jsayol is probably right that we should add that check.

@gauntface
Copy link

The SDK should perform an additional check here:

@jshcrowthe
Copy link
Contributor

jshcrowthe commented Jun 28, 2017

We have merged #79 at it will go out in the next release. Thanks for the issue @skstronghold!

@firebase firebase locked and limited conversation to collaborators Oct 27, 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

5 participants