Skip to content

Commit

Permalink
Handle non existing deeplink app (#355)
Browse files Browse the repository at this point in the history
* Handle browser termination on opening non existent app

* Format

* Format

* Combine if statements

Co-authored-by: Aashish Gurung <[email protected]>

* Fix `if` syntax

---------

Co-authored-by: Aashish Gurung <[email protected]>
  • Loading branch information
AnasNaouchi and aashishgurung authored Sep 10, 2024
1 parent dd8d70f commit 35ef80f
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AuthorizingPaymentActivity : AppCompatActivity() {
private val uiCustomization: UiCustomization by lazy { intent.parcelable(EXTRA_UI_CUSTOMIZATION) ?: UiCustomization.default }
private lateinit var threeDSRequestorAppURL: String
private var isWebViewSetup = false
private var isDeepLinkSuccOpened = false
private lateinit var externalActivityLauncher: ActivityResultLauncher<Intent>

private val viewModel: AuthorizingPaymentViewModel by viewModels {
Expand Down Expand Up @@ -253,12 +254,14 @@ class AuthorizingPaymentActivity : AppCompatActivity() {
}

private fun openDeepLink(uri: Uri) {
try {
val externalIntent = Intent(Intent.ACTION_VIEW, uri)
externalActivityLauncher.launch(externalIntent)
} catch (e: ActivityNotFoundException) {
finishActivityWithFailure(OmiseException(OmiseSDKError.OPEN_DEEP_LINK_FAILED.value, e))
}
isDeepLinkSuccOpened =
try {
val externalIntent = Intent(Intent.ACTION_VIEW, uri)
externalActivityLauncher.launch(externalIntent)
true
} catch (e: ActivityNotFoundException) {
false
}
}

private fun setupActionBarTitle() {
Expand Down Expand Up @@ -302,7 +305,7 @@ class AuthorizingPaymentActivity : AppCompatActivity() {
resultCode: Int,
data: Intent?,
) {
if (requestCode == REQUEST_EXTERNAL_CODE) {
if (requestCode == REQUEST_EXTERNAL_CODE && isDeepLinkSuccOpened) {
finishActivityWithSuccessful(data)
}
}
Expand Down

0 comments on commit 35ef80f

Please sign in to comment.