BugProgOriginal post
Rank 2: Process
Hello !
I'm trying to use Appwrite push Notification.
I set up the Push Notification in Appwrite settings without any issue.
I can also send push notification from the Appwrite console to my Android App.
Now I'm trying to send the push notification with an Appwrite function.
I have the following code:
JavaScript
import {Client, Users, ID, Messaging} from 'node-appwrite';
export default async ({req, res, log, error}) => { const client = new Client() .setEndpoint(process.env.APPWRITE_FUNCTION_API_ENDPOINT) .setProject(process.env.APPWRITE_FUNCTION_PROJECT_ID) .setKey(req.headers['x-appwrite-key'] ?? ''); const users = new Users(client); const messaging = new Messaging(client);
try { const response = await users.list(); log(`Total users: ${response.total}`);
const message = await messaging.createPush( ID.unique(), "HI !", "Hello", [], ["68399458000c67552a3f"] ); } catch (err) { error(err); } return res.json({ motto: "Build like a team of hundreds_", learn: "https://appwrite.io/docs", connect: "https://appwrite.io/discord", getInspired: "https://builtwith.appwrite.io", });};But I get :
AppwriteException: Message with the requested ID could not be found.
at _Client.call (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:278:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Messaging.createPush (file:///usr/local/server/src/function/node_modules/node-appwrite/dist/services/messaging.mjs:276:12)
at async Module.default (file:///usr/local/server/src/function/src/main.js:15:21)
at async execute (/usr/local/server/src/server.js:208:16)
at async action (/usr/local/server/src/server.js:225:7)
at async /usr/local/server/src/server.js:14:5
Do you know why ? I don't understand the error.
Thank you for your help 🙂
Summary
Developers are trying to send a push notification with Appwrite function but getting an error "Message with the requested ID could not be found." The issue might be with the ID of the message. Double-check the message ID used in the code.