How to interact with firebase?

  • 0
    I am trying to get a token on js using firebase but it gives me 404 error
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js">
    </head>
    <meta charset="utf-8">
    </head>
    <body>
    <!-- The core Firebase JS SDK is always required and must be listed first -->
    <script src="https://push-app-66813.firebaseapp.com/__/firebase/8.0.2/firebase>
    
    <!-- TODO: Add SDKs for Firebase products that you want to use
         https://firebase.google.com/docs/web/setup#available-libraries -->
    <script src="https://push-app-66813.firebaseapp.com/__/firebase/8.0.2/firebase>

    function pernot(){
                            switch(Notification.permission.toLowerCase())
                            {
                               case ("granted"):
                                 subscribe();
                                    break;
                               case ("denied"):
                                 console.log("denied");
                                    break;
                               case ("default"):
                                 Notification.requestPermission(function(state){
                                    if (state =="granted")
                                            subscribe();
                                    if (state=="default")
    setTimeout("pernot", 3000);
                            });
                                    break;
                            }
    }
    
                    function subscribe(){
                            var msg = firebase.messaging();
                            msg.requestPermission().
                            then(function(){
                            msg.getToken().then(function(token){
                            alert(token)}).
                            catch(function(err){alert("not to accept");});
    }).
                            catch(function(){alert(err);}
                            );
    }
                                    pernot();

    What could be the problem?
    JavaScript Kira Pierce, Nov 18, 2020

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!