App Rejected Due to Apple Login
mehroozkhan opened this issue · 5 comments
Describe the bug
Our app has been rejected from app store multiple times because apple team keep getting error when they try Apple Login.
Message From Apple Review Team on every build submission is:
The app exhibited one or more bugs that would negatively impact App Store users.
Bug description: Sign in with Apple process failed to proceed.
Review device details:
- Device type: iPad Air (5th generation)
- OS version: iOS 17.5.1
We have tested our apps in development mode and in Test Flight multiple times with different apple accounts, never got any error.
On Investigating the Amplify Error code, it is the AuthError.InvalidState error.
Login Code:
`func socialSignInWithWebUI(provider: AuthProvider?) async {
let signInResult: AuthSignInResult
do {
if let provider = provider {
signInResult = try await Amplify.Auth.signInWithWebUI(for: provider,presentationAnchor: self.view.window!)
} else {
signInResult = try await Amplify.Auth.signInWithWebUI(presentationAnchor: self.view.window!)
}
if signInResult.isSignedIn {
let userInfo = try? await Amplify.Auth.getCurrentUser()
onLogin?(userInfo?.username, nil)
}
} catch {
print("Unexpected error: \(error)")
self.viewModel.showLoader.value = false
self.viewModel.alertMessage.value = AlertMessage(title: "Error", body: error.localizedDescription)
}
}`
Also tried with the .preferPrivateSession() option, still rejected with this too.
Steps To Reproduce
We can't reproduce it on our end.
Expected behavior
Apple Review team successfully login and approve the app.
Amplify Framework Version
2.35.4
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.10
CLI version
12.10.1
Xcode version
15.4
Relevant log output
<details>
<summary>Log Messages</summary>
INSERT LOG MESSAGES HERE
Is this a regression?
No
Regression additional context
No response
Platforms
iOS
OS Version
iOS 17.5.1
Device
iPad Air (5th generation)
Specific to simulators
No response
Additional context
No response
Hi @mehroozkhan, thanks for opening this issue.
We'll take a look and see if we can figure out what might be happening and post updates here
Hi @mehroozkhan ,
Before displaying the sign-in UI, did you check the user's auth status? One potential issue that could cause the Amplify.AuthError.invalidState
error is attempting to initiate a sign-in process when there is already an active and valid user session.
@5d Thanks for your reply. Yes I do check first if the user is signed in or not through fetchAuthSession API.
static func configure(splashSeen: Bool = false, onboarding: Bool, registration: Bool, keychainServices: KeychainServicesProtocol, completion: @escaping (LaunchInstructor)->Void) {
Task {
let result = await fetchCurrentAuthSession(keychainServices: keychainServices)
if !splashSeen {
completion(.splash)
}
else if !onboarding {
completion(.onboarding)
}
else if result {
completion(.main)
} else {
completion(.auth)
}
}
}
static func fetchCurrentAuthSession(keychainServices: KeychainServicesProtocol) async -> Bool {
do {
let session = try await Amplify.Auth.fetchAuthSession()
if let cognitoTokenProvider = session as? AuthCognitoTokensProvider {
let tokens = try cognitoTokenProvider.getCognitoTokens().get()
keychainServices.setAPIToken(token: tokens.idToken)
}
return session.isSignedIn
} catch {
return false
}
}