fix : firebase

Deskripsi
:
- fix error emty token firebase

NO Issues
This commit is contained in:
2025-08-21 15:31:27 +08:00
parent 19c99534c5
commit 20032301e8

View File

@@ -22,7 +22,7 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
title, title,
body, body,
}, },
tokens:token, tokens: token,
data, data,
android: { android: {
priority: "high", priority: "high",
@@ -44,6 +44,7 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
}, },
}; };
if (token.length > 0) {
// 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) {
@@ -56,6 +57,9 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
const del = await deleteDeviceError({ device: failedTokens }); const del = await deleteDeviceError({ device: failedTokens });
} }
}
return { success: true, message: "Notifikasi berhasil dikirim", }; return { success: true, message: "Notifikasi berhasil dikirim", };
} catch (error) { } catch (error) {
console.error("Error mengirim notifikasi:", error); console.error("Error mengirim notifikasi:", error);