42 lines
932 B
JavaScript
42 lines
932 B
JavaScript
|
|
// Initialize Firebase
|
|
// const firebaseconfig = {
|
|
// apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
|
// authDomain: "test-667ca.firebaseapp.com",
|
|
// databaseURL: "https://test-667ca.firebaseio.com",
|
|
// projectId: "test-667ca",
|
|
// storageBucket: "test-667ca.appspot.com",
|
|
// messagingSenderId: "221332577314"
|
|
// };
|
|
// firebase.initializeApp(firebaseconfig);
|
|
|
|
|
|
|
|
var msg = firebase.messaging();
|
|
msg.requestPermission()
|
|
.then(function(){
|
|
console.log("Zugriff auf msg")
|
|
return msg.getToken();
|
|
})
|
|
.then(token => {
|
|
console.log("MSG TOKEN: ", token)
|
|
|
|
})
|
|
.catch(err => {
|
|
console.error("Msg Error: ", err)
|
|
})
|
|
|
|
axios.post('/user', {
|
|
message_id: 'test',
|
|
})
|
|
.then(function (response) {
|
|
console.log(response);
|
|
})
|
|
.catch(function (error) {
|
|
console.log(error);
|
|
});
|
|
|
|
msg.onMessage(payload => {
|
|
const title = payload.data.title
|
|
new Notification(title, { body: payload.data.text});
|
|
}) |