braintree / braintree-android-drop-in

Braintree Drop-In SDK for Android
https://developers.braintreepayments.com/guides/drop-in/android/v2
MIT License
124 stars 79 forks source link

Provide Instant Apps compatibility #20

Closed mrsasha closed 1 year ago

mrsasha commented 7 years ago

Hi,

do you have any info on if/when you'll be providing Instant Apps compatibility? Looking at the available info (https://developer.android.com/topic/instant-apps/prepare.html), there's item 2 i.e. Also, an activity cannot launch another activity directly within an instant app; rather, it must request the URL address that corresponds to that activity.

Effectively there's no activity opening and no onActivityResult but everything would need to be communicated via app links (https://developer.android.com/training/app-links/index.html).

Thanks!

lkorth commented 7 years ago

I was just reading that last night from the round of emails Google sent out yesterday 😄.

There is only 1 issue in two places that prevents Drop-in (specifically the code in this repo) from working well in instant apps. Drop-in is started as an Activity via Activity#startActivityForResult and if a user chooses to use a card it starts one more Activity via Activity#startActivityForResult. This is pretty minor and could be solved with either of the two following options:

  1. Move Drop-in to a 100% Fragment based UI and refactor the existing Activitys to use these Fragments for backwards compatibility. This would allow a developer to start a Drop-in Fragment and never worry about calling Activity#onActivityResult. Although this would require some minor updates for developers wishing to use Drop-in in instant apps, this is ultimately the most maintainable approach.
  2. Add optional support for app links. This would require the developer to start Drop-in with their base url and most likely also perform some additional initial setup in the Android manifest. Because app links are only available on API 23 and up and setting them up is reasonably lengthy and complex we'd need to maintain two code paths, one that uses app links when a base url is supplied to Drop-in and one that uses Activity#startActivityForResult as it currently does. Due to the complexity in the code, setup and documentation this is the less preferable approach.

Drop-in is built on top of the Braintree Android SDK and uses it for all of it's communication with Braintree. The Braintree Android SDK also runs into some of the instant app limitations including not using Activity#startActivityForResult and:

Discover or interact directly with the list of installed apps on the device (e.g. via explicit intents).

The following are limitations any use of the Braintree Android SDK would run into in instant apps when using certain payment methods:

  1. 3D Secure would need to be updated to not use Activity#startActivityForResult.
  2. Until there is an update to Android Pay to use app links, Android Pay would not be useable in an instant app because the masked and full wallet requests make calls inside of Google Play Services Wallet to Activity#onActivityResult.
  3. When an app is run as an instant app it cannot discover or interact with other apps on the device. This would currently prevent PayPal and Venmo app switches until a point in the future when both apps support app links. In order for these apps to support app links they would also need to have a similar web UI in the case that the app is not installed on the device and the user ends up on a web page (instant apps cannot discover which apps are installed on the device so the current detection of the PayPal and Venmo apps is not possible in an instant app). This would be a relatively minor issue for PayPal since the Braintree Android SDK already supports PayPal in a browser or Chrome Custom Tab.

As it stands today, only cards (including UnionPay) and PayPal via browser switch would be supported in instant apps by the Braintree Android SDK. With one of the above changes to Drop-in, it could also support these payment methods. Additional changes would be required by other parties to support Android Pay, Venmo and PayPal app switches in instant apps.

Please let us know what you think of these options and limitations!

Note: As of January 9th, 2017 30.3% of devices are on API 23 or above and would support app links + instant apps.

mrsasha commented 7 years ago

Hi Luke,

sorry for my late reply but I was in the process of obtaining some further info from the Google guys. So, when it comes to the approach, the first one is preferable, I would say - removing the Activity/onActivityResult wouldn't be complicated neither from the library nor the app standpoint.

When it comes to limitations, I have some more info, but cannot talk about specifics at the moment:

  1. that would need to be updated, but I don't know how many people use 3DSecure
  2. this is not a problem
  3. using browser for payments might currently be problematic.

As for our app users, we currently have around 57% on Android 6 and further 7% on Android 7, which means that probably more than 50% of our target group would be able to use Instant Apps.

lkorth commented 7 years ago

Thanks for the follow up @mrsasha. We'll hopefully be getting some more information and the chance to test instant apps before they become generally available. I'll leave this issue open and include any additional information that becomes available as well as include it on any relevant commits in the future.

mrsasha commented 7 years ago

Thanks!

mrsasha commented 7 years ago

Hi, just saw that this is still open - Google is using their own Google Payments API for AIA payments, so I think we can close this issue now.

lkorth commented 7 years ago

This should remain open, there is still work that needs to be done on Drop-in for instant apps. Apps can still use saved payment methods outside of the Google Payments API and Drop-in can also add support the Google Payments API.

scannillo commented 1 year ago

👋 Closing this issue due to lack of community engagement and since there is no current plan to include it on our product roadmap.

Feel free to re-open on this issue or reach out to Braintree Developer Support if this is something your app still needs!