This is the way to initialize the Daraja API in Kotlin. Problem is, I get a type mismatch on the forth parameter of Dajara.with(1st, 2nd, 3rd, 4th) function. The error is at the object : DarajaListener parameter.
daraja = Daraja.with("CONSUME_KEY", "CONSUMER_SECRET_KEY", Env.SANDBOX,
**object : DarajaListener<AccessToken>** {
override fun onResult(result: AccessToken) {
Toast.makeText(applicationContext, result.access_token, Toast.LENGTH_SHORT).show()
}
override fun onError(error: String?) {
Toast.makeText(applicationContext, error.toString(), Toast.LENGTH_SHORT).show()
}
})
The build error is as follows:
Type mismatch: inferred type is but DarajaListener<AccessToken!>! was expected
Hovering the cursor around the error flashes this message:
Type mismatch. Required:DarajaListener<AccessToken!>!Found:
Any help initializing it the right way?