I am evaluating google cloud pub/sub to send messaging to my JavaScript client application (ionic, angular app). I couldn’t find any sample code for subscribing pub/sub messaging in JavaScript.
JFYI: I have nodejs on server-side.
There is no client library provided for Javascript. If you want to access messages from Javascript, you will have to make HTTP pull requests. In order to make these requests, they will need to be authorized. That means you would have to have making OAuth2 access token requests for a service account from your client application.
In general, Google Cloud Pub/Sub is not going to be the best way to send messages from a server to client applications that are run by your users unless you have very tight control over who the users are that are accessing the app. Additionally, since there is a limit of 10,000 subscriptions in Google Cloud Pub/Sub, you could only ever have 10,000 users receive the full stream of messages. Instead, you might want to consider Firebase Cloud Messaging for this type of use case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With