From a7106b00daba7d240a332781123c9658424d2aa8 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Fri, 8 Nov 2024 12:58:45 +0530 Subject: [PATCH 1/6] Added the transaction active error FAQ --- FAQ.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/FAQ.md b/FAQ.md index 9b3e1581..594d9270 100644 --- a/FAQ.md +++ b/FAQ.md @@ -8,6 +8,7 @@ - [2. How can I disable the _logout_ alert box?](#2-how-can-i-disable-the-logout-alert-box) - [3. How can I change the message in the alert box?](#3-how-can-i-change-the-message-in-the-alert-box) - [4. How can I programmatically close the alert box?](#4-how-can-i-programmatically-close-the-alert-box) +- [5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error ?](#-5-how-to-resolve-the-failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment-error) --- @@ -140,6 +141,14 @@ Auth0.swift has no control whatsoever over the alert box. Its contents cannot be Auth0.swift has no control whatsoever over the alert box. It cannot be closed programmatically. Unfortunately, that is a limitation of `ASWebAuthenticationSession`. +## 5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error ? + +Users might encounter this error when the login/logout alert box is displayed and the user locks the device and unlocks it again. The alert box would have been dismissed but when the user tries to log in again, the error is shown. +This is a known issue with `ASWebAuthenticationSession` and it is not specific to Auth0.swift . We have already raised an issue with Apple and are waiting for a response from them. +Meanwhile , as a workaround, developers can invoke `WebAuthentication.cancel()` to manually clear the current login transaction when encountering this error. +Please ensure to not cancel a valid login attempt (eg: the login page is open, and the user switches briefly to another app and then returns) . + --- + [Go up ⤴](#frequently-asked-questions) From 543ebc73bad3249542f39b1cc8e93042f2356c4c Mon Sep 17 00:00:00 2001 From: Prince Mathew <17837162+pmathew92@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:06:15 +0530 Subject: [PATCH 2/6] FAQ changes as per suggestions Co-authored-by: Rita Zerrizuela --- FAQ.md | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/FAQ.md b/FAQ.md index 594d9270..4e942976 100644 --- a/FAQ.md +++ b/FAQ.md @@ -141,13 +141,25 @@ Auth0.swift has no control whatsoever over the alert box. Its contents cannot be Auth0.swift has no control whatsoever over the alert box. It cannot be closed programmatically. Unfortunately, that is a limitation of `ASWebAuthenticationSession`. -## 5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error ? +## 5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error? -Users might encounter this error when the login/logout alert box is displayed and the user locks the device and unlocks it again. The alert box would have been dismissed but when the user tries to log in again, the error is shown. -This is a known issue with `ASWebAuthenticationSession` and it is not specific to Auth0.swift . We have already raised an issue with Apple and are waiting for a response from them. -Meanwhile , as a workaround, developers can invoke `WebAuthentication.cancel()` to manually clear the current login transaction when encountering this error. -Please ensure to not cancel a valid login attempt (eg: the login page is open, and the user switches briefly to another app and then returns) . +Users might encounter this error when the app moves to the background and then back to the foreground while the login/logout alert box is displayed, for example by locking and unlocking the device. The alert box would get dismissed but when the user tries to log in again, the Web Auth operation fails with the `transactionActiveAlready` error. +This is a known issue with `ASWebAuthenticationSession` and it is not specific to Auth0.swift. We have already filed a bug report with Apple and are awaiting for a response from them. + +### Workarounds + +#### Clear the login transaction when handling the `transactionActiveAlready` error + +You can invoke `WebAuthentication.cancel()` to manually clear the current login transaction upon encountering this error. Then, you can retry login. For example: + +```swift +switch error { +case .failure(let error) where error == .transactionActiveAlready: + WebAuthentication.cancel() + // ... retry login +// ... +} --- From 57a555c37284d76d47b52f82d9f3b6f7600d5445 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Mon, 11 Nov 2024 14:14:12 +0530 Subject: [PATCH 3/6] fixed the anchor not working links --- FAQ.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/FAQ.md b/FAQ.md index 4e942976..621e7712 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,14 +1,14 @@ # Frequently Asked Questions -- [1. How can I disable the _login_ alert box?](#1-how-can-i-disable-the-login-alert-box) +- [1. How can I disable the _login_ alert box?](#1-how-can-i-disable-the-_login_-alert-box) - [Use ephemeral sessions](#use-ephemeral-sessions) - [Use `SFSafariViewController`](#use-sfsafariviewcontroller) - [1. Configure a custom URL scheme](#1-configure-a-custom-url-scheme) - [2. Capture the callback URL](#2-capture-the-callback-url) -- [2. How can I disable the _logout_ alert box?](#2-how-can-i-disable-the-logout-alert-box) +- [2. How can I disable the _logout_ alert box?](#2-how-can-i-disable-the-_logout_-alert-box) - [3. How can I change the message in the alert box?](#3-how-can-i-change-the-message-in-the-alert-box) - [4. How can I programmatically close the alert box?](#4-how-can-i-programmatically-close-the-alert-box) -- [5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error ?](#-5-how-to-resolve-the-failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment-error) +- [5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error?](#5-how-to-resolve-the-_failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment_-error) --- @@ -161,6 +161,6 @@ case .failure(let error) where error == .transactionActiveAlready: // ... } --- - +``` [Go up ⤴](#frequently-asked-questions) From 673b6394ba80b130fcff04c7f33ec7b38da189f7 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Mon, 11 Nov 2024 14:17:50 +0530 Subject: [PATCH 4/6] FAQ anchor link issue --- FAQ.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FAQ.md b/FAQ.md index 621e7712..da3cab9f 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1,14 +1,14 @@ # Frequently Asked Questions -- [1. How can I disable the _login_ alert box?](#1-how-can-i-disable-the-_login_-alert-box) +- [1. How can I disable the _login_ alert box?](#1-how-can-i-disable-the-login-alert-box) - [Use ephemeral sessions](#use-ephemeral-sessions) - [Use `SFSafariViewController`](#use-sfsafariviewcontroller) - [1. Configure a custom URL scheme](#1-configure-a-custom-url-scheme) - [2. Capture the callback URL](#2-capture-the-callback-url) -- [2. How can I disable the _logout_ alert box?](#2-how-can-i-disable-the-_logout_-alert-box) +- [2. How can I disable the _logout_ alert box?](#2-how-can-i-disable-the-logout-alert-box) - [3. How can I change the message in the alert box?](#3-how-can-i-change-the-message-in-the-alert-box) - [4. How can I programmatically close the alert box?](#4-how-can-i-programmatically-close-the-alert-box) -- [5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error?](#5-how-to-resolve-the-_failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment_-error) +- [5. How to resolve the _Failed to start this transaction, as there is an active transaction at the moment_ error?](#5-how-to-resolve-the-failed-to-start-this-transaction-as-there-is-an-active-transaction-at-the-moment-error) --- From c714795248040173d8dfd8e6c45afd882c366c04 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Mon, 11 Nov 2024 14:19:33 +0530 Subject: [PATCH 5/6] Minor formatting --- FAQ.md | 1 - 1 file changed, 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index da3cab9f..574dab72 100644 --- a/FAQ.md +++ b/FAQ.md @@ -160,7 +160,6 @@ case .failure(let error) where error == .transactionActiveAlready: // ... retry login // ... } ---- ``` [Go up ⤴](#frequently-asked-questions) From b7435e349d44c4325a17605e5176347763c1e5a8 Mon Sep 17 00:00:00 2001 From: Prince Mathew Date: Tue, 12 Nov 2024 10:44:47 +0530 Subject: [PATCH 6/6] Added the missed FAQ update --- FAQ.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FAQ.md b/FAQ.md index 574dab72..07cbbb3f 100644 --- a/FAQ.md +++ b/FAQ.md @@ -162,4 +162,10 @@ case .failure(let error) where error == .transactionActiveAlready: } ``` +#### Clear the login transaction when the app moves to the background/foreground +You can invoke `WebAuthentication.cancel()` to manually clear the current login transaction when the app moves to the background or back to the foreground. However, you need to make sure to not cancel valid login attempts –for example, when the user switches briefly to another app while the login page is open. + +#### Avoid the login/logout alert box +If you don't need SSO, consider using `ephemeral sessions` or `SFSafariViewController` instead of `ASWebAuthenticationSession`. See [1. How can I disable the _login_ alert box?](#1-how-can-i-disable-the-login-alert-box) for more information. + [Go up ⤴](#frequently-asked-questions)