Skip to content
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

dropInClient.launchDropInForResult allow Fragments or better registerForActivityResult #313

Closed
mtrakal opened this issue Nov 26, 2021 · 13 comments

Comments

@mtrakal
Copy link

mtrakal commented Nov 26, 2021

General information

  • SDK/Library version: 6.0.0.
  • Environment: sandbox
  • Android Version and Device: any

Issue description

dropInClient.launchDropInForResult() requires Activity. But in this case startActivityForResult is called on activity, not in attached fragment. So result is returned to activity and not into active fragment.

Expected behavior

launchDropInForResult accept Fragments, so we can expect result in Fragment and not only in activity.

Or even better accept Activity Result APIs lambda function to handle result in callback through registerForActivityResult. More info about Activity Result APIs:
https://developer.android.com/training/basics/intents/result
https://medium.com/e-legion/the-right-way-to-get-a-result-part-i-activity-result-api-6efbcaa5600d

@sarahkoop
Copy link
Contributor

Hi @mtrakal, thanks for using the Braintree Android Drop-in SDK. We will look into this and post an update here when we have more information.

@ZuTappJoe
Copy link

Any update on this? Earlier versions had "startActivityForResult" instead of "launchDropInForResult", and that worked for calling the Fragments onActivityResult. However, that is depreceated and earlier versions are more buggy.

PLEASE update this to allow fragments to receive the result like before!!

@sarahkoop
Copy link
Contributor

@ZuTappJoe We are actively working on this. The Braintree iOS Drop-in SDK relies on the Braintree Android SDK, so we are working to ensure that the approach we take is feasible and consistent across SDKs. We appreciate your patience!

@surfmast3r
Copy link

Hi @sarahkoop , still no update on this issue?

@sshropshire
Copy link
Contributor

@surfmast3r we've released a new integration method in version 4.9.+ of our core SDK that uses the registerForActivityResult API result internally. We'll be prioritizing effort to support this integration method in our DropIn SDK soon.

@valeh962
Copy link

valeh962 commented Apr 5, 2022

@sshropshire Hi, is there any news about new integration ?

@sshropshire
Copy link
Contributor

@valeh962 we have PR #337 up and once it's merged in we'll be able to push a release with the new integration pattern.

@Docik
Copy link

Docik commented May 3, 2022

Hey @sshropshire , Is there any information about planned release dates?

@mattwylder
Copy link
Contributor

Thanks for your patience everyone, this has been released in 6.1.0!

@fabiorbap
Copy link

@mattwylder I updated my SDK to 6.1.0 but there I didn't find any of these methods, and in #315 there is a comment in the changelog saying it was "unreleased", is this code really available in 6.1.0 or am I doing something wrong?

@sshropshire
Copy link
Contributor

@fabiorbap apologies for this! We had a slight oversight. I've created a draft PR with the missing method.

It's worth mentioning that if DropInClient is instantiated with either a Fragment or Activity and a listener is set, launchDropInForResult(null, 0) will work in the meantime.

@fabiorbap
Copy link

@sshropshire Thank you so much for such a fast response!

Got it, no worries, I will for the new release then, and use the parameters you mentioned for it to work properly.

However, I saw in #315 that there was a class DropInLauncher which was what I had initially thought to be used instead of the DropInClient, but should I use the new method when it's deployed then?

Thank you!

@sshropshire
Copy link
Contributor

@fabiorbap yup! launchDropIn() with no parameters will be the correct method to use. In #315 we learned that it's better to create an activity launcher internally that has access to the DropInClient to further process a result once it's received.

Using the listener pattern allows a merchant to fully recover a completed (or canceled) flow that was interrupted by a process kill using a single integration pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants