in sdk/communication/azure-communication-chat/src/main/java/com/azure/android/communication/chat/implementation/notifications/fcm/RegistrarClient.java [166:212]
public void unregister(String skypeUserToken) throws Throwable {
if (registrationId == null) {
return;
}
String registrarServiceUrl = getRegistrarServiceUrl(skypeUserToken);
String unregisterUrl = registrarServiceUrl + "/" + registrationId;
HttpRequest request = new HttpRequest(HttpMethod.DELETE, unregisterUrl);
request
.setHeader(USER_AGENT_HEADER, PLATFORM_UI_VERSION)
.setHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON)
.setHeader(SKYPE_TOKEN_HEADER, skypeUserToken);
CountDownLatch latch = new CountDownLatch(1);
final Throwable[] requestError = { null };
this.httpClient.send(request, CancellationToken.NONE, new HttpCallback() {
@Override
public void onSuccess(HttpResponse response) {
int statusCode = response.getStatusCode();
RegistrarClient.this.logger.info("Registrar unregister http response code:" + statusCode);
if (statusCode != 202) {
requestError[0] = new RuntimeException("Registrar unregister request failed with http status code "
+ statusCode
+ ". Error message: "
+ response.getBodyAsString()
);
}
latch.countDown();
}
@Override
public void onError(Throwable error) {
requestError[0] = error;
latch.countDown();
}
});
awaitOnLatch(latch);
if (requestError[0] != null) {
throw logger.logThrowableAsError(requestError[0]);
}
logger.info("Unregister succeed! RegistrationId:" + registrationId);
}