Add image to embedded payment option display data#2032
Conversation
| // Direct access to imageLoader and call it synchronously with timeout | ||
| val imageBase64 = | ||
| try { | ||
| val imageLoaderField = this@toWritableMap.javaClass.getDeclaredField("imageLoader") |
There was a problem hiding this comment.
This might not work if the merchant uses progaurd/R8.
That being said, I'm not convinced this is the right approach to begin with!
What are you trying to do here?
There was a problem hiding this comment.
Trying to access the imageLoader, which is private, any chance we can make it like RESTRICT_TO ilb?
| try { | ||
| // Load synchronously with 5 second timeout | ||
| val drawable = | ||
| kotlinx.coroutines.runBlocking { |
There was a problem hiding this comment.
What thread does this happen on?
There was a problem hiding this comment.
Looks like it is running on the main thread which isn't great! However, it is consistent with the iOS native lib 🙈.
I pushed up a change to run it on a different thread than main, however my Android threading knowledge is limited so lmk what you think. Verified it still works too.
| // Load synchronously with 5 second timeout | ||
| val drawable = | ||
| kotlinx.coroutines.runBlocking { | ||
| withTimeout(5000L) { |
There was a problem hiding this comment.
Is there a way to fallback if something fails?
There was a problem hiding this comment.
We could fallback, but I think we'd need to bundle some resource in the RN SDK. My preference would be that the imageLoader resolves with some default/placeholder image if loading fails to keep the logic out of the RN SDK. Unsure what "generic" payment method icon we could use. My immediate reaction is a card icon, but that may be inaccurate for most payment method types.
Summary
Motivation
Testing