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

Remove onNewIntent Override in MainActivity #311

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

sshropshire
Copy link
Collaborator

Summary of changes

  • We no longer need to override onNewIntent in the Demo app's MainActivity
  • This PR refactors each Composable to use OnNewIntentEffect internally

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@sshropshire sshropshire requested a review from a team as a code owner January 28, 2025 16:33
@@ -48,7 +49,11 @@ fun ApproveOrderView(
val context = LocalContext.current
OnLifecycleOwnerResumeEffect {
val intent = context.getActivityOrNull()?.intent
intent?.let { viewModel.completeAuthChallenge(intent) }
intent?.let { viewModel.completeAuthChallenge(it) }
Copy link
Collaborator

@KunJeongPark KunJeongPark Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to check onResume as well as newIntent if we are assuming singeTop launch mode?
Is there a chance that this is called the second time in onResume?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good callout. This is need for process kill, but I do need to make sure we're doing Activity state restoration and I'll debug with "Don't keep activities" to make sure it's being called.

@@ -235,18 +235,25 @@ class ApproveOrderViewModel @Inject constructor(
OrderInfo(orderId, status, didAttemptThreeDSecureAuthentication)
}
approveOrderState = ActionState.Success(orderInfo)
// discard authState
authState = null
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mentioned in the v2_MIGRATION_GUIDE but it was missing here.

The merchant needs to discard authState when they are done to prevent stale auth state from being parsed again to check for auth completion when a merchant app comes back into the foreground. Notice authState is not discarded when .NoResult is returned by the SDK.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u explain that a bit Steven? why authState is not discarded with .NoResult?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in the demo app, keeping authState when we can't determine if the user completed the flow allows the user to retry launching the browser-switched flow.

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 this pull request may close these issues.

2 participants