upd: fcm modifikasi
This commit is contained in:
22
xsendMany.ts
22
xsendMany.ts
@@ -7,9 +7,9 @@ const enc = "U2FsdGVkX1+ATdSSI7vdTGLCA8f6WjifHPoesp/SXL2VtKVRV4QkKjrU/CYBxWyA48n
|
||||
const decrypt = CryptoJs.AES.decrypt(enc, "amal").toString(CryptoJs.enc.Utf8)
|
||||
|
||||
// Fungsi untuk mengirim notifikasi FCM
|
||||
export async function sendFCMNotificationMany(token: string[]) {
|
||||
export async function sendFCMNotificationMany({ token, title, body, data }: { token: string[], title: string, body: string, data: { id: string, category: string, content: string } }) {
|
||||
// const serviceAccount = await fs.readFile(path.join(process.cwd(), "key.json"));
|
||||
if(getApps().length === 0){
|
||||
if (getApps().length === 0) {
|
||||
initializeApp({
|
||||
credential: cert(JSON.parse(decrypt)),
|
||||
});
|
||||
@@ -19,16 +19,11 @@ export async function sendFCMNotificationMany(token: string[]) {
|
||||
// Konfigurasi pesan
|
||||
const message = {
|
||||
notification: {
|
||||
title: "Notifikasi Many Encrypted api downgrade",
|
||||
body: "Isi notifikasi ke banyak device key diencrypt dan api downgrade",
|
||||
title,
|
||||
body,
|
||||
},
|
||||
token,
|
||||
data: {
|
||||
id: 'cm1eqwkwj00067j2bzejyh9u7',
|
||||
category: 'division',
|
||||
content: 'cm1eqwkvu00017j2b8qnisp9g',
|
||||
},
|
||||
// Opsional: konfigurasi Android
|
||||
data,
|
||||
android: {
|
||||
priority: "high",
|
||||
notification: {
|
||||
@@ -57,9 +52,4 @@ export async function sendFCMNotificationMany(token: string[]) {
|
||||
console.error("Error mengirim notifikasi:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// sendFCMNotificationMany([
|
||||
// 'c89yuexsS_uc1tOErVPu5a:APA91bEb6tEKXAfReZjFVJ2mMyOzoW_RXryLSnSJTpbIVV3G0L_DCNkLuRvJ02Ip-Erz88QCQBAt-C2SN8eCRxu3-v1sBzXzKPtDv-huXpkjXsyrkifqvUo',
|
||||
// 'cRz96GHKTRaQaRJ35e8Hxa:APA91bEUSxE0VPbqKSzseQ_zGhbYsDofMexKykRw7o_3z2aPM9YFmZbeA2enrmb3qjdZ2g4-QQtiNHAyaZqAT1ITOrwo9jVJlShTeABmEFYP5GLEUZ3dlLc'
|
||||
// ])
|
||||
}
|
||||
Reference in New Issue
Block a user