0

I'm trying to implement ReachFive in my android app and I have to call the initialize method.

This is how they call it in the documentation:

    // Initialize the ReachFive client
    client.initialize({ providers ->
        // On success, do something with the retrieved list of providers registered for this ReachFive client
        // ...
    }, {
        // On failure, log the error message returned by the ReachFive client
        Log.d("Reach5_MainActivity", "ReachFive init ${it.message}")
    })

But this code sample is in Kotlin and I have no idea how to call the initialize method in java.

Edit: This is the initialize function find inside the SDK code:

fun initialize(
    success: Success<List<Provider>> = {},
    failure: Failure<ReachFiveError> = {}
): ReachFive {
    reachFiveApi
        .clientConfig(mapOf("client_id" to sdkConfig.clientId))
        .enqueue(
            ReachFiveApiCallback<ClientConfigResponse>(
                success = { clientConfig ->
                    scope = clientConfig.scope.split(" ").toSet()
                    providersConfigs(success, failure)
                },
                failure = failure
            )
        )

    return this
}
1

1 Answer 1

2

Try this (put the implementation/logic of your functions instead of dots)

client.initialize((providers) -> {...}, (error) -> {...}); 

Note that your first method should return an instance of Success<List<Provider>> and your second lambda should return Failure<ReachFiveError>.

Sign up to request clarification or add additional context in comments.

2 Comments

That's it ! Thank you :)
@R3J3CT3D you are welcome! Please note, that the method above simply passes objects of Functional Interface to initialize method. In my answer I declared them anonymously, whereas they can also be declared explicitly. You should read about it more

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.