-
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
6.5.0 DropInClient - Method addObserver must be called on the main thread #374
Comments
Hi @molchanovskiy thanks for using the Braintree SDK for Android. This limitation exists because we use the underlying Jetpack Lifecycle#addObserver() method internally, which imposes the Are you able to instantiate a DropIn client in your Activity / Fragment's |
Hi @sshropshire |
@sshropshire Here is our module which should open DropIn on user click Pay button
|
Correct yes. One option is to asynchronously fetch a client token and forward it via bundle args, although this can be tricker. The best option here is to instantiate a |
@sshropshire The new change makes react-native development a lot harder. Because my current flow is let our backend API to return customer braintree token and let the DropInClient launch the dropin UI by token in v5. But it requires a provider to retrieve the customer braintree token in native Android/iOS instead of JS thread in v6, which will double the work for mobile cross platform tools. Will Braintree Android SDK implement the same way of dropin UI as v5 in future? Or Braintree Android/iOS dropin SDK no longer consider mobile cross platform development tools in terms of usability and ease of use? |
@molchanovskiy You can try the old way to call something onCreate() in MainActivity. facebook/react-native#3334 (comment) |
Hi @sshropshire Is there any way to update DropInClient token on already instantiated client? I mean if client is instantiated in my MainActivity onCreate() method and later to update token from react native module? |
@molchanovskiy at the moment no. Internally the SDK needs the client token to make backend calls on the merchant's behalf. Adding this feature could create a ton of race conditions for the SDK. |
@wayson the old way of instantiating a |
@sshropshire Thanks for your reply. I've tried that but DropInClient can only be called in onCreate() on Activity. Otherwise we will have error of I've also tried
But the app just crash straight away after this call. |
@wayson Activity onCreate():
|
Hi @molchanovskiy @sshropshire I have followed the same solution which is given by @molchanovskiy. But the problem I'm facing is, dropInClient.setListener is not triggered once I completed the payment. Both onDropInSuccess and onDropInFailure is not triggered. My Mainactivity snippet:
In module call:
Please look into this issue. |
@Kowshika-aspire I can see now how this makes it difficult to use DropIn with React Native. We may have to consider this as a feature request for our next major version. Would the ideal DropIn API for React Native be to allow |
@sshropshire Thanks for the reply. Currently, We are using 5.3.0 which has cardinal SDK issue. So, We need to update drop-in version to the latest one as you suggested on this PR Click here Can you suggest any solution to resolve the issue? |
I am also trying to upgrade the drop-in library in our RN app to 6.5.0, due to cardinal SDK issue.
I'm writing in Java and it didn't work, while @molchanovskiy seems to be able to get it working in Kotlin. |
@Kowshika-aspire @zhenghow93 we've released 5.4.0 to help in the meantime while migrating to @zhenghow93 it is ideal that the listener is set shortly after the Is there an ideal API for DropIn on React Native we should consider for our next major version? It seems like the Activity lifecycle are unavailable at the JavaScript level? |
@sshropshire thanks for your prompt reply. Is v5.4.0 using compliant cardinal SDK? |
@zhenghow93 yes. We made a small patch to include the latest version of the Cardinal SDK to help extend the migration window for merchants. |
I am working on react native module for DropIn and getting this error on initialization of DropInClient
implementation "com.braintreepayments.api:drop-in:6.5.0
Method addObserver must be called on the main thread
Why this error can appear?
The text was updated successfully, but these errors were encountered: