Y
Y
Yan White2020-11-16 14:35:10
JavaScript
Yan White, 2020-11-16 14:35:10

How to interact with firebase?

I'm trying to get a js token using firebase, but it gives me a 404 error5fb261a375106161830054.jpeg

<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?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question