fix : firebase notification
Deskripsi: - empty array token undefined > semua fitur - update api version No Issues
This commit is contained in:
@@ -263,7 +263,7 @@ export async function POST(request: Request) {
|
|||||||
data: dataNotifFilter
|
data: dataNotifFilter
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Pengumuman Baru",
|
title: "Pengumuman Baru",
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
tokenDup.push(perbekel?.TokenDeviceUser.map((v: any) => v.token).flat())
|
tokenDup.push(perbekel?.TokenDeviceUser.map((v: any) => v.token).flat())
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Komentar Baru",
|
title: "Komentar Baru",
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ export async function POST(request: Request) {
|
|||||||
data: dataNotif
|
data: dataNotif
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Diskusi Umum Baru",
|
title: "Diskusi Umum Baru",
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export async function POST(request: Request, context: { params: { id: string } }
|
|||||||
tokenDup.push(perbekel?.TokenDeviceUser.map((v: any) => v.token).flat())
|
tokenDup.push(perbekel?.TokenDeviceUser.map((v: any) => v.token).flat())
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Komentar Baru",
|
title: "Komentar Baru",
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ export async function POST(request: Request) {
|
|||||||
data: dataNotifFilter
|
data: dataNotifFilter
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
|
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
|
|||||||
@@ -392,7 +392,7 @@ export async function POST(request: Request) {
|
|||||||
data: dataNotifFilter
|
data: dataNotifFilter
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Kegiatan Baru",
|
title: "Kegiatan Baru",
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ export async function POST(request: Request) {
|
|||||||
data: dataNotifFilter
|
data: dataNotifFilter
|
||||||
})
|
})
|
||||||
|
|
||||||
const tokenUnique = [...new Set(tokenDup.flat())];
|
const tokenUnique = [...new Set(tokenDup.flat())].filter((v: any) => v != undefined && v != null && v != "");
|
||||||
await sendFCMNotificationMany({
|
await sendFCMNotificationMany({
|
||||||
token: tokenUnique,
|
token: tokenUnique,
|
||||||
title: "Tugas Baru",
|
title: "Tugas Baru",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET(request: Request) {
|
||||||
try {
|
try {
|
||||||
return NextResponse.json({ success: true, version: "1.7.6", tahap: "beta", update: "-api mobile; -tambah laporan pada project dan tugas divisi; -tambah upload link pada project dan tugas divisi; -tambah detail tanggal dan jam pada project dan tugas divisi" }, { status: 200 });
|
return NextResponse.json({ success: true, version: "1.7.7", tahap: "beta", update: "-api mobile; -tambah laporan pada project dan tugas divisi; -tambah upload link pada project dan tugas divisi; -tambah detail tanggal dan jam pada project dan tugas divisi" }, { status: 200 });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
return NextResponse.json({ success: false, version: "Gagal mendapatkan version, coba lagi nanti (error: 500)", reason: (error as Error).message, }, { status: 500 });
|
||||||
|
|||||||
@@ -43,10 +43,8 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
console.log("masuk", token.length, token)
|
|
||||||
|
|
||||||
if (token.length > 0) {
|
if (token.length > 0) {
|
||||||
console.log("Token", token.length)
|
|
||||||
// Kirim pesan
|
// Kirim pesan
|
||||||
const response = await getMessaging().sendEachForMulticast(message as any);
|
const response = await getMessaging().sendEachForMulticast(message as any);
|
||||||
if (response.failureCount > 0) {
|
if (response.failureCount > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user