3

I am not receiving real-time developer notifications from Google play store. I have followed following steps:

  1. Set up GOOGLE_APPLICATION_CREDENTIALS

  2. Set up Listener for messages. Code for message receiver

    public List<ReceivedMessage> recieveAndroidNotification() throws IOException {
    
        String subscriptionId = "my-project-id";
        String projectId = "my-subscription-id";
        SubscriberStubSettings subscriberStubSettings = SubscriberStubSettings.newBuilder().build();
        try (SubscriberStub subscriber = GrpcSubscriberStub.create(subscriberStubSettings)) {
            // String projectId = "my-project-id";
            // String subscriptionId = "my-subscription-id";
            int numOfMessages = 10; // max number of messages to be pulled
            String subscriptionName = ProjectSubscriptionName.format(projectId, subscriptionId);
            PullRequest pullRequest = PullRequest.newBuilder().setMaxMessages(numOfMessages).setReturnImmediately(false) // return immediately if messages are not available
                    .setSubscription(subscriptionName).build();
    
            // use pullCallable().futureCall to asynchronously perform this operation
            PullResponse pullResponse = subscriber.pullCallable().call(pullRequest);
            List<String> ackIds = new ArrayList<>();
            for (ReceivedMessage message : pullResponse.getReceivedMessagesList()) {
                // handle received message
                // ...
                System.out.println("Message Recived");
                ackIds.add(message.getAckId());
            }
            // acknowledge received messages
            AcknowledgeRequest acknowledgeRequest = AcknowledgeRequest.newBuilder().setSubscription(subscriptionName).addAllAckIds(ackIds)
                    .build();
            // use acknowledgeCallable().futureCall to asynchronously perform this operation
            subscriber.acknowledgeCallable().call(acknowledgeRequest);
            return pullResponse.getReceivedMessagesList();
        }
    }
    
  3. Publishes a test notification to the Cloud Pub/Sub topic, thereby verifying the setup and configuration of that topic prior to real-time notifications being received. (Haven't received notification)

  4. Run code manually then it send error:

    WARN [2018-06-06 06:37:02,479] com.google.auth.oauth2.ComputeEngineCredentials: Failed to detect whether we are running on Google Compute Engine.

Am I missing something?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Sandesh Dumbre
  • 226
  • 2
  • 9
  • Possible duplicate of [How can i set the environment variable GOOGLE\_APPLICATION\_CREDENTIALS?](https://stackoverflow.com/questions/50019736/how-can-i-set-the-environment-variable-google-application-credentials) – Mangu Jun 11 '18 at 07:38

0 Answers0