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

ActivityResultContracts / Compose #169

Open
YiffyToys opened this issue Dec 20, 2021 · 5 comments
Open

ActivityResultContracts / Compose #169

YiffyToys opened this issue Dec 20, 2021 · 5 comments

Comments

@YiffyToys
Copy link

The SDK should allow to use the current ActivityResultContracts in addition of the deprecated mechanism in Activity.
This is required to use the SDK in Jetpack Compose applications where rememberLauncherForActivityResult() is the prefered way to
start other activities when interacting with UI elements and handle the results.

@LuK1709
Copy link

LuK1709 commented Jan 14, 2022

This would also be useful without Compose, as the currently used mechanism is deprecated and ActivityResultsContract would allow for greater flexibility when processing the payment results.

@YiffyToys
Copy link
Author

Half a year has passed and nothing happened. This issue hasn't even been triaged yet.

@YiffyToys
Copy link
Author

YiffyToys commented May 1, 2022

I wonder if something like this may work until SumUp gets their act together:

class SumUpPaymentForResult : ActivityResultContract<SumUpPayment, ActivityResult>() {
        override fun createIntent(context: Context, input: SumUpPayment): Intent {
            class DummyActivity: Activity() {
                var capturedIntent: Intent? = null
                override fun startActivityForResult(intent: Intent?, requestCode: Int) {
                    capturedIntent = intent
                }

                override fun getPackageName(): String {
                    return "myapp.package"
                }
            }

            val dummy = DummyActivity()
            SumUpAPI.checkout(dummy, input, 1)
            return dummy.capturedIntent!!
        }

        override fun parseResult(
            resultCode: Int,
            intent: Intent?
        ): ActivityResult = ActivityResult(resultCode, intent)
    }

@bahuma20
Copy link

I wonder if something like this may work until SumUp gets their act together

Can confirm that this workaround is working. 👍

But still: SumUp please add typed ActivityResultContracts 🙏

@YiffyToys
Copy link
Author

Wow, is it already 3 years without catching up to the 2022 state of the art?

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

No branches or pull requests

3 participants