-
Notifications
You must be signed in to change notification settings - Fork 465
Closed
Labels
needs more infoThis issue needs more information from the customer to proceed.This issue needs more information from the customer to proceed.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.
Description
Hello,
i'm trying to send message via Firebase Cloud Messaging but i received the below error so can you please help in fixing this issue
java.util.concurrent.ExecutionException: com.google.firebase.messaging.FirebaseMessagingException: Error while calling FCM backend service
..
Caused by: java.io.IOException: Error getting access token for service account: connect timed out
code snippets :-
FileInputStream serviceAccount =
new FileInputStream("serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://testnf-42343.firebaseio.com")
.build();
FirebaseApp defaultApp =FirebaseApp.initializeApp(options);
System.err.println(defaultApp.getName());
UUID uuid = UUID.randomUUID();
String registrationToken = FirebaseAuth.getInstance().createCustomToken(uuid.toString());
// See documentation on defining a message payload.
Message message = Message.builder()
.putData("score", "850")
.putData("time", "2:45")
.setToken(registrationToken)
.build();
// Send a message to the device corresponding to the provided
// registration token.
FirebaseMessaging instance = FirebaseMessaging.getInstance();
String response;
try {
response = instance.sendAsync(message).get();
// response = instance.send(message);
// Response is a message ID string.
System.out.println("Successfully sent message: " + response);
} catch (Exception e) {
e.printStackTrace();
}
Metadata
Metadata
Assignees
Labels
needs more infoThis issue needs more information from the customer to proceed.This issue needs more information from the customer to proceed.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.