Solution 1 :
You would not want to receive the Cloud Pub/Sub message in the application itself. In order to accomplish this, you would need to have a subscription per application instance and Cloud Pub/Sub is not designed to scale that way: the limit is 10,000 subscriptions per topic. Additionally, each instance of the application would receive all notifications for all users, which is likely not what you want.
The purpose of the real time developer notifications is for your service to receive notifications of changes to users’ entitlements. Then, when users make requests to your service from the application, it can respond appropriately based on the subscription features that should be enabled. If you want an application instance to be notified when entitlements change, you’d have to implement that separately in the service in response to the Cloud Pub/Sub notifications. You could use something like Firebase Cloud Messaging to send the appropriate messages to individual application instances. However, you would still need to have a service that acts as a subscriber to Cloud Pub/Sub and gets the messages from the topic for developer notifications and then passes these along to Firebase Cloud Messaging.
I am building a app with in-app subscriptions. I have implemented Real Time developer notifications as recommended by Google by properly configuring as mentioned over there. Whenever I purchase or cancel a subscription, SubscriptionNotification is published to the Pub/Sub topic as expected. But I am not able to get that message in the app. My requirement is that whenever message is published to the topic same message must be received inside app without any explicit request. And I have a pull subscription of Google’s Pub/Sub api. So does pull suit here or should I go for push? So any kind of help would be highly appreciated.
Comment posted by Nadeem Shaikh
I got your point but one more question….what should be the type of subscription in Google Pub/Sub topic, Pull or push? I have created a pull. Have I done it right?
Comment posted by Kamal Aboul-Hosn
That depends on how you plan to build your subscriber. If you are going to use put it behind an HTTPS endpoint and you want Pub/Sub to send messages to it, then push is the appropriate choice. If you plan to call the Pub/Sub subscribe API (likely through the client libraries), then pull is the right choice.