-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification.php
43 lines (41 loc) · 1.73 KB
/
notification.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!-- Insert these scripts at the bottom of the HTML, but before you use any Firebase services -->
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-messaging.js"></script>
<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<!--<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-analytics.js"></script>
-->
<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.12.0/firebase-firestore.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyCmIr87Ihp8nXtHrKWZyeH1GcvFrHxmtJw",
authDomain: "alnahr-3a32e.firebaseapp.com",
databaseURL: "https://alnahr-3a32e.firebaseio.com",
projectId: "alnahr-3a32e",
storageBucket: "alnahr-3a32e.appspot.com",
messagingSenderId: "410160983978",
appId: "1:410160983978:web:22a64081a20724ec9185d3",
measurementId: "G-QYSFSMTB8R"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// firebase.analytics();
const messaging = firebase.messaging();
messaging.requestPermission()
.then(function() {
console.log("Ture");
return messaging.getToken();
})
.then(function(token) {
console.log(token);
})
.catch(function(err) {
console.log("error")
});
messaging.onMessage(function(payload) {
console.log('onmessage', payload);
});
</script>