Когда я устанавливаю производство: true, я получаю ошибку «плохой токеной устройства».
Как я могу отправить уведомление на телефон при проходе обновляется?
Код: Выделить всё
sendPassUpdateNotification: async (data) => {
try {
const devices = [
{
pushToken: "5555555555555555",
deviceLibraryIdentifier: "55555555555555",
},
];
for (const device of devices) {
const { pushToken, deviceLibraryIdentifier } = device;
if (!pushToken) {
console.log(`❌ No push token for device: ${deviceLibraryIdentifier}`);
continue;
}
let a = new Date();
const notification = new apn.Notification({
topic: "pass.test",
pushType: "alert",
contentAvailable: true,
payload: {
userId: "12345",
passUpdatedAt: a.toISOString()
},
aps: {
alert: {
title: "Pass Updated",
body: "Your pass has been successfully updated."
},
badge: 1,
sound: "default"
},
});
const response = await apnProvider.send(notification, pushToken);
if (response.failed && response.failed.length) {
console.error("Failed deliveries:", response.failed);
}
}
} catch (error) {
console.error("❌ Error in sendPassUpdateNotification:", error);
}
},
Подробнее здесь: https://stackoverflow.com/questions/794 ... is-updated
Мобильная версия