forked from ahmedbechirmezhoud/CSTC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
32 lines (24 loc) · 858 Bytes
/
db.js
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
import { initializeApp } from "firebase/app";
import { getFirestore, collection, getDocs } from "firebase/firestore";
const firebaseConfig = {
apiKey: "AIzaSyBQH0riI5e09XX-pEcjvhCMAQEz2gvhDMY",
authDomain: "cstc-2a071.firebaseapp.com",
projectId: "cstc-2a071",
storageBucket: "cstc-2a071.appspot.com",
messagingSenderId: "669579499696",
appId: "1:669579499696:web:dab2291f0cc2886d0b8375",
measurementId: "G-LYQL9V1W9K"
};
initializeApp(firebaseConfig);
const db = getFirestore();
export async function getTokens(){
let PushTokens = [];
const querySnapshot = await getDocs(collection(db, "users/"));
querySnapshot.forEach((doc) => {
if(doc.data()?.notificationToken){
PushTokens.push(doc.data()?.notificationToken);
console.log("sending to " + doc.data()?.name);
}
});
return PushTokens;
}