mass notifs working
This commit is contained in:
parent
286e6aabcb
commit
0290c170bb
3 changed files with 7 additions and 8 deletions
|
|
@ -81,9 +81,8 @@ export async function sendAdminNotification(data: {
|
|||
|
||||
try {
|
||||
const [ticket] = await expo.sendPushNotificationsAsync([message]);
|
||||
console.log(`Notification sent:`, ticket);
|
||||
} catch (error) {
|
||||
console.error(`Failed to send notification:`, error);
|
||||
console.log(`Failed to send notification:`, error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ import { sendAdminNotification } from '@/src/lib/notif-job'
|
|||
import { handleOrderCancelled, handleOrderPlaced } from '@/src/lib/post-order-handler'
|
||||
|
||||
export const handleNotifQueue =async (batch: any) => {
|
||||
console.log('notif batch,', {batch})
|
||||
batch.messages.forEach(async (message: any) => {
|
||||
|
||||
for (const message of batch.messages || []) {
|
||||
const body = message?.body
|
||||
if (!body) {
|
||||
console.log('notif_queue message received with empty body')
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
if (body.name === 'send-admin-notification' && body.jobData?.token) {
|
||||
|
|
@ -17,11 +17,11 @@ export const handleNotifQueue =async (batch: any) => {
|
|||
body: body.jobData.body,
|
||||
imageUrl: body.jobData.imageUrl ?? null,
|
||||
})
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
// console.log('notif_queue', body)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export const handleOrderPlacedQueue = async (batch: any) => {
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ export const userRouter = {
|
|||
tokens = userTokens.map(t => t.token);
|
||||
}
|
||||
|
||||
tokens = ['ExponentPushToken[w4KTsLKnnp8SbURdl5-Q6x]', 'ExponentPushToken[81Io9TG3Qg0s3N0V8L86T-]', 'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]', 'ExponentPushToken[LQZgYkFG_3CweaUbv0fBKJ]']
|
||||
// tokens = ['ExponentPushToken[w4KTsLKnnp8SbURdl5-Q6x]', 'ExponentPushToken[81Io9TG3Qg0s3N0V8L86T-]', 'ExponentPushToken[YJRSQmMUEUbaI2VCZLaoN_]', 'ExponentPushToken[LQZgYkFG_3CweaUbv0fBKJ]']
|
||||
|
||||
// Queue one job per token
|
||||
let queuedCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue