Hi all, I want to use Notify | Velo to send a notification to a site member, but I get this error: “Error sending notification: message: Not Found details: applicationError: description: Not Found code: NOT_FOUND data: {}”
This is the backend code:
import { Permissions, webMethod } from "wix-web-module";
import { notifications } from "wix-notifications.v2";
import * as wixAuth from 'wix-auth';
export const notifyWithElevation = webMethod(
Permissions.SiteMember,
async (body, channels, options) => {
try {
const elevatedNotify = wixAuth.elevate(notifications.notify);
const result = await elevatedNotify(body, channels, options);
return result;
} catch (error) {
throw new Error("Notification failed");
}
}
);
This is the frontend code:
$w.onReady(function () {
const body = "This is the body of the notification";
const channels = ["Browser", "Mobile"];
const options = {
title: "Notification Title",
toContacts: {
contactIds: ["XXXXXXX-2115-444e-a332-XXXXXXXX"],
},
targetUrl: "https://example.com"
};
notifyWithElevation(body, channels, options)
.then((result) => {
console.log("Notification sent successfully", result);
})
.catch((error) => {
console.error("Notification failecsfsd", error);
});
});
I also tried sending it “toSiteContributors”, same error. Can you help? Thank you so much!