-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to register DropInClient within coroutines or suspend functions or view model #467
Comments
Hey @AG-Akash09, thanks for the message. We’re aware of limitations with the current constructor and would need to make a breaking change to truly resolve this issue. We may investigate this further and publish a long term fix as part of a beta release of our next major version but this is not on our current roadmap. In the meantime, the following workaround strategy may work:
|
@AG-Akash09 can you try removing the outer |
Braintree SDK Version
6.15.0
Environment
Both
Android Version & Device
No response
Braintree dependencies
Describe the bug
Our network calls are seamlessly integrated with coroutines and view models. To retrieve the client token from our server, we employ a suspend function and observe its value in the onCreateView function. However, attempting to pass the client token to DropInClient results in a crash, accompanied by the error 'java.lang.IllegalStateException: LifecycleOwner MembershipFragment is attempting to register while current state is RESUMED. LifecycleOwners must call register before they are STARTED.' Although registering directly with the DropInClient within onCreateView using the tokenization key works flawlessly, we're constrained by the tokenization key's limitations, necessitating our reliance on the client token exclusively.
To reproduce
Code Snippet
viewModel.paymentToken.observe(viewLifecycleOwner, Observer {
Log.d("Payment Token ","$it")
val fragmentActivity = requireActivity();
dropInClient = DropInClient(fragmentActivity,it)
val dropInRequest = DropInRequest()
Expected behavior
DropInClient should registered successfully
Screenshots
The text was updated successfully, but these errors were encountered: