fix : firebase
Deskripsi : - fix error emty token firebase NO Issues
This commit is contained in:
26
xsendMany.ts
26
xsendMany.ts
@@ -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,18 +44,22 @@ export async function sendFCMNotificationMany({ token, title, body, data }: { to
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kirim pesan
|
if (token.length > 0) {
|
||||||
const response = await getMessaging().sendEachForMulticast(message as any);
|
// Kirim pesan
|
||||||
if (response.failureCount > 0) {
|
const response = await getMessaging().sendEachForMulticast(message as any);
|
||||||
const failedTokens: any[] = [];
|
if (response.failureCount > 0) {
|
||||||
response.responses.forEach((resp, idx) => {
|
const failedTokens: any[] = [];
|
||||||
if (!resp.success) {
|
response.responses.forEach((resp, idx) => {
|
||||||
failedTokens.push(token[idx]);
|
if (!resp.success) {
|
||||||
}
|
failedTokens.push(token[idx]);
|
||||||
});
|
}
|
||||||
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user