Hello, I can't use the messaging.createPush function in a node.js server function. If I use null for the optional parameters as shown below:
message = await messaging.createPush(
ID.unique(), // messageId
title, // title
body, // body
[], // topics (optional)
users || [], // users (optional)
targets || [], // targets
data || {}, // data
null, // action (optional)
null, // image (optional)
null, // icon (optional)
sound, // sound (optional)
null, // color (optional)
null, // tag (optional)
null, // badge (optional)
false, // draft (optional)
null // scheduledAt (optional)
);
I get the following error in the Appwrite container log:
2024-06-19 01:44:29 [Error] Method: POST 2024-06-19 01:44:29 [Error] URL: /v1/messaging/messages/push 2024-06-19 01:44:29 [Error] Type: TypeError 2024-06-19 01:44:29 [Error] Message: {closure}(): Argument #8 ($action) must be of type string, null given, called in /usr/src/code/vendor/utopia-php/framework/src/App.php on line 531 2024-06-19 01:44:29 [Error] File: /usr/src/code/app/controllers/api/messaging.php 2024-06-19 01:44:29 [Error] Line: 2876
And if I replace null
with an empty string ''
like this:
message = await messaging.createPush(
ID.unique(), // messageId
title, // title
body, // body
[], // topics (optional)
users || [], // users (optional)
targets || [], // targets
data || {}, // data
'', // action (optional)
'', // image (optional)
'', // icon (optional)
sound, // sound (optional)
'', // color (optional)
'', // tag (optional)
'', // badge (optional)
false, // draft (optional)
'' // scheduledAt (optional)
);
Then, I get the following error:
2024-06-19 01:31:10 [Error] Method: POST 2024-06-19 01:31:10 [Error] URL: /v1/messaging/messages/push 2024-06-19 01:31:10 [Error] Type: Utopia\Exception 2024-06-19 01:31:10 [Error] Message: Invalid
action
param: Value must be a valid string and at least 1 chars and no longer than 256 chars 2024-06-19 01:31:10 [Error] File: /usr/src/code/vendor/utopia-php/framework/src/App.php 2024-06-19 01:31:10 [Error] Line: 774
I see at line 2876 in app/controllers/api/messaging.php the action parameter is a string $action
so not null
Thank you for your help
Recommended threads
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...