Skip to content

Callback not triggered after connecting device via Settings intent #106

@aliiraj

Description

@aliiraj

Hi
I'm using the following code to launch the Zettle Settings screen, where the user can connect a payment device. After the device is connected, I expect the result to be returned to the ActivityResultLauncher so I can save the connected device. However, the callback is not triggered after connecting a device. It only triggers (with a cancel state) after the user manually presses the back arrow in the Settings screen.

val connectLauncher =
rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) { activityResult ->
if (activityResult.resultCode != Activity.RESULT_OK) {
return@rememberLauncherForActivityResult
}

        when (activityResult.data?.zettleResult()) {
            is ZettleResult.Completed<*> -> {
                viewModel.dispatchIntent(ConnectPaymentDeviceIntent.SaveDevice)
            }

            else -> {}
        }
    }

val intent = CardReaderAction.Settings.show(context)
connectLauncher.launch(intent)

Expected behavior:
After the user connects a device via the Zettle Settings screen, the result should be returned, triggering the ZettleResult.Completed case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions