swift – Google Cloud Pub/Sub integration in iOS
There are two approaches to publish/receive messages from Google Cloud Pub/Sub.
-
Make a call to the Cloud Pub/Sub REST API.
You’ll be using your preferred iOS REST client SDK to handle the REST request and response. You do need to take care the REST API authentication as documented here. One drawback of connecting directly to the REST endpoint is that you end up embedding or parameterizing the GCP specific information such as GCP project and Pub/Sub topic information in your mobile app. Which could be some overhead when upgrading or release new mobile apps. -
Use a gateway/proxy for Cloud Pub/Sub.
The idea is to build a mobile backend that proxies Pub/Sub requests. The gateway implementation can be AppEngine, Cloud Run or GKE (Kubernetes). The flow looks something like following:
iOS app -> GKE Pub/Sub Proxy -> Cloud Pub/Sub -> DataFlow (or other services)
The proxy can handle some Cloud and Pub/Sub specific functions such as authentication, Pub/Sub message batching etc. Essentially offload them from the mobile app side, provide a better separation pattern.
Here is one example of setting up Pub/Sub proxy on GKE.
Read more here: Source link