Merge branch 'master' of https://github.com/LukasNowy/SmartShopper
This commit is contained in:
27
express-server/public/firebase-messaging-sw.js
Normal file
27
express-server/public/firebase-messaging-sw.js
Normal file
@ -0,0 +1,27 @@
|
||||
// Give the service worker access to Firebase Messaging.
|
||||
// Note that you can only use Firebase Messaging here, other Firebase libraries
|
||||
// are not available in the service worker.
|
||||
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-app.js');
|
||||
importScripts('https://www.gstatic.com/firebasejs/4.8.1/firebase-messaging.js');
|
||||
|
||||
// Initialize the Firebase app in the service worker by passing in the
|
||||
// messagingSenderId.
|
||||
firebase.initializeApp({
|
||||
'messagingSenderId': 'YOUR-SENDER-ID'
|
||||
});
|
||||
|
||||
// Retrieve an instance of Firebase Messaging so that it can handle background
|
||||
// messages.
|
||||
const messaging = firebase.messaging();
|
||||
|
||||
|
||||
|
||||
messaging.setBackgroundMessageHandler(payload => {
|
||||
// const title = payload.data.title
|
||||
// const options = {
|
||||
// body: payload.data.text
|
||||
// }
|
||||
// return self.registration.showNotification(title, options)
|
||||
const title = payload.data.title
|
||||
new Notification(title, { body: payload.data.text});
|
||||
})
|
@ -6,11 +6,13 @@ var config = {
|
||||
projectId: "test-667ca",
|
||||
storageBucket: "test-667ca.appspot.com",
|
||||
messagingSenderId: "221332577314"
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
firebase.initializeApp(config);
|
||||
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/shoppinglistx idtoken:", idtoken);
|
||||
@ -108,7 +110,7 @@ function eigeneEinkaufslisten(){
|
||||
},
|
||||
success(res){
|
||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
||||
console.log("/userinfo_json idtoken: ",idtoken)
|
||||
console.log("/userinfo_json idtoken: ",idtoken)
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/userinfo_json",
|
||||
@ -116,17 +118,19 @@ function eigeneEinkaufslisten(){
|
||||
idtoken: idtoken
|
||||
},
|
||||
success(data){
|
||||
let userinfo = "jhsbdjhf";
|
||||
// console.log(userinfo);
|
||||
|
||||
const userinfo = data.name;
|
||||
const picture = data.picture;
|
||||
console.log(data)
|
||||
for(let i = 0; i < res.length; i++){
|
||||
const el = res[i];
|
||||
|
||||
$(".listen-ausgabe").append(`<div class="col-md-12 karten">
|
||||
<div class="card border-light mb-3" style="max-width: 18rem;" id="${el.sl_id}">
|
||||
<div class="card-header">
|
||||
<span>${userinfo}</span>
|
||||
<button class="btn edit"><i class="fas fa-angle-down"></i></button>
|
||||
<span>
|
||||
<img src="${picture}" alt="Avatar" style="width:10%; border-radius: 50%;">
|
||||
${userinfo}</span>
|
||||
<button class="btn edit"><i class="fas fa-pencil-alt "></i></button>
|
||||
<button class="btn trash"><i class="far fa-trash-alt"></i></button>
|
||||
<button class="btn groupadd" data-toggle="modal" data-target=".ListenDetailAdd"><i class="fas fa-ellipsis-v"></i></button>
|
||||
</div>
|
||||
@ -246,7 +250,28 @@ function Detail(){
|
||||
|
||||
const neu = result.filter(obj => obj.sl_id === id);
|
||||
|
||||
$(".card-header").append(`<h1 class="text-center">${neu[0].name}</h1><button class="btn itemadd"><ion-icon name="more" size="large"></ion-icon></button>
|
||||
var link = "/dash/"+idtoken;
|
||||
|
||||
//ITEM ADD
|
||||
// von Card Header Kopiert
|
||||
|
||||
// <a href="" class="itemadd">
|
||||
// <i class="fas fa-plus"></i>
|
||||
// </a>
|
||||
|
||||
$(".card-header").append(`
|
||||
<a href="${link}" style="left: 5px; margin-top: -50px">
|
||||
<i class="fas fa-caret-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<h1 class="text-center">
|
||||
${neu[0].name}
|
||||
</h1>
|
||||
|
||||
|
||||
|
||||
`);
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const el = res[i];
|
||||
|
32
express-server/public/javascripts/firebase-app.js
Normal file
32
express-server/public/javascripts/firebase-app.js
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
// 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)
|
||||
})
|
||||
|
||||
msg.onMessage(payload => {
|
||||
const title = payload.data.title
|
||||
new Notification(title, { body: payload.data.text});
|
||||
})
|
Reference in New Issue
Block a user