Hi
in my messaging before publish event handler i want to add a property in the header of the message.
how can i do that?
If you want to add the header through the SDK, you can use PublishOptions. Here is the sample code for Android:
Map<String, String> headers = new HashMap<>();
headers.put("headerName", "headerValue");
PublishOptions publishOptions = new PublishOptions();
publishOptions.setHeaders(headers);
Backendless.Messaging.publish((Object) "My message", publishOptions);
Best Regards,
Maksym
I want to add the header property in the “beforePublish” event handler.
im doing some calculations in the event and i want to pass that to the subscribed users
Sorry, my mistake.
You can add the header to the PublishOptions
in your event handler too. The beforePublish
method receives the PublishOptions
, so you can use the same code above.
Best Regards,
Maksym
Hello,
This is how the PublishOptions
should be structured:
Notice there is headers
property, which should contain object containing headers/values.
Regards,
Mark
Could you check the contents of Request Publish Options
after the property is set and before the event handler is done? This can be done using the print
block and then checking in the real-time logging window when the API is executed.
it does have it
headers: { Request_id: 'request', ToUser: 'AAFCD463-3BF0-B20C-FF3B-C47584300000', FromUser: 'AAFCD463-3BF0-B20C-FF3B-C47584300000', ggg: '33' }
Thanks. Do you use real-time messaging to subscribe to the channel to receive messages or retrieve them using the REST endpoint?
i use the JS SDK to subscribe to the channel
Internal ticket was created: BKNDLSS-21797.
We’ll let you know about solution.
Best regards,
Yevgen
Hello @mohammad_altoiher,
the BKNDLSS-21797 ticket status is “Waiting for test”. We’ll notify you here as soon at it will be completed.
Regards,
Olha
We’ve released the new version of Backendless. Please, could you be so kind to confirm that the issue disappears?
Best regards,
Yevgen
i can add the header property but i get this when i want to return a the “created” column.
is this normal?
converting it to string first was the solution.