public void register()

in sdk/communication/azure-communication-chat/src/main/java/com/azure/android/communication/chat/implementation/notifications/fcm/RegistrarClient.java [118:164]


    public void register(
        String skypeUserToken,
        String deviceRegistrationToken,
        SecretKey cryptoKey,
        SecretKey authKey) throws Throwable {
        String registrarServiceUrl = getRegistrarServiceUrl(skypeUserToken);
        HttpRequest request = new HttpRequest(HttpMethod.POST, registrarServiceUrl);
        request
            .setHeader(USER_AGENT_HEADER, PLATFORM_UI_VERSION)
            .setHeader(CONTENT_TYPE_HEADER, CONTENT_TYPE_JSON)
            .setHeader(SKYPE_TOKEN_HEADER, skypeUserToken);

        addRequestBody(request, deviceRegistrationToken, cryptoKey, authKey);

        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 register http response code:" + statusCode);
                if (statusCode != 202) {
                    requestError[0] = new RuntimeException("Registrar register 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]);
        }

        this.logger.info("Register succeed! RegistrationId:" + registrationId);
    }