Ok, for those who wonder, here is what I have come up with:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | var messages = { 'messages': [ { 'data': base64Encode(utf8.encode('{"foo": "bar"}')), }, ] }; pubSubClient.projects.topics .publish(new PublishRequest.fromJson(messages), "your topic") .then((publishResponse) { debugPrint(publishResponse.toString()); }).catchError((e,m){ debugPrint(e.toString()); }); |
Maybe someone should write an article on it, this was not very clear and I had to try different things and also read the source from the pubsub client library.
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.