[READ] Step 1: Are you in the right place?
Yes, I'm in the right place.
[REQUIRED] Step 2: Describe your environment
- Operating System version: macos
- Firebase SDK version: ?
- Library version: 6.7.0
- Firebase Product: messaging
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
When sending push notifications, how do I access http response headers? As per documentation here I have to respect Retry-After header in case of messaging/server-unavailable and messaging/internal-error error codes.
By looking into the code, it appears that http headers get ignored.
Relevant Code:
ApiFuture<String> future = FirebaseMessaging.getInstance(firebaseApp).sendAsync(message);
future.addListener(() -> {
try {
String id = future.get();
LOGGER.debug("FCM message has been sent successfully: {} / {}", id, notificationMessage.getId());
sendToEndpoint(MARK_PENDING_NOTIFICATION_AS_SENT_ENDPOINT, notificationMessage);
} catch (InterruptedException e) {
LOGGER.debug("Sending a push notification {} was interrupted", notificationMessage.getId(), e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
if (cause instanceof FirebaseMessagingException) {
FirebaseMessagingException fcmException = (FirebaseMessagingException) cause;
handleFirebaseMessagingException(notificationMessage, fcmException);
//TODO implement exponential backoff retry mechanism and respect 'Retry-After' http header response
} else {
LOGGER.debug("Unexpected error of sending FCM message: {}. Marking the notification as failed.",
notificationMessage.getId(), e);
sendToEndpoint(MARK_PENDING_NOTIFICATION_AS_FAILED_ENDPOINT, notificationMessage);
}
}
}, executor);
[READ] Step 1: Are you in the right place?
Yes, I'm in the right place.
[REQUIRED] Step 2: Describe your environment
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
When sending push notifications, how do I access http response headers? As per documentation here I have to respect
Retry-Afterheader in case ofmessaging/server-unavailableandmessaging/internal-errorerror codes.By looking into the code, it appears that http headers get ignored.
Relevant Code: