在我的应用程序中,我实现了Google任务,这样我的用户就可以收到关于他们的ToDo项目何时到期的通知。
我的主要问题是,当我的云任务触发时,我注意到它仍然位于我的Cloud控制台中。那么,一旦他们被解雇了,他们会不会删除自己呢?对于我的应用程序,我希望云任务完成后可以删除它们自己。
我在文档中注意到,这行you can also fine-tune the configuration for the task, like scheduling a time in the future when it should be executed or limiting the number of times you want the task to be retried if it fails.的问题是,我的任务没有失败,但是我看到retries的数量是4。
firebase cloud functions
exports.firestoreTtlCallback = functions.https.onRequest(async (req, res) => {
try {
const payload = req.body;
let entry = await (await admin.firestore().doc(payload.docPath).get()).data();
let tokens = await (await admin.firestore().doc(`/users/${payload.uid}`).get()).get('tokens')
await admin.messaging().sendMulticast({
tokens,
notification: {
title: "App",
body: entry['text']
}
}).then((response) => {
log('Successfully sent message:')
log(response)
}).catch((error) => {
log('Error in sending Message')
log(error)
})
const taskClient = new CloudTasksClient();
let { expirationTask } = admin.firestore().doc(payload.docPath).get()
await taskClient.deleteTask({ name: expirationTask })
await admin.firestore().doc(payload.docPath).update({ expirationTask: admin.firestore.FieldValue.delete() })
res.status(200)
} catch (err) {
log(err)
res.status(500).send(err)
}
})发布于 2021-08-13 18:34:14
如果任务已排定或分派,则可以删除该任务。如果任务已根据此文档成功或永久失败,则无法删除该任务。
任务将作为HTTP请求推送给工作人员。如果工作人员或重定向工作人员通过返回成功的HTTP响应代码(200-299)来确认任务,则如果返回任何其他HTTP响应代码或没有收到响应,则任务将按照此文档.从队列中删除,该任务将根据以下步骤重新尝试:
https://stackoverflow.com/questions/68765522
复制相似问题