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

App Rejected Due to Apple Login #3795

Closed
mehroozkhan opened this issue Jul 29, 2024 · 5 comments
Closed

App Rejected Due to Apple Login #3795

mehroozkhan opened this issue Jul 29, 2024 · 5 comments
Labels
auth Issues related to the Auth category bug Something isn't working

Comments

@mehroozkhan
Copy link

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

Attachment:
Screenshot-0724-153544

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

@ruisebas ruisebas added bug Something isn't working auth Issues related to the Auth category labels Jul 29, 2024
@ruisebas
Copy link
Member

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

@5d
Copy link
Member

5d commented Jul 30, 2024

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.

@mehroozkhan
Copy link
Author

@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
        }
    }

@mehroozkhan
Copy link
Author

our app got approved without changing anything in the apple login now. Very strange Apple!

Copy link
Contributor

github-actions bot commented Aug 4, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Issues related to the Auth category bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants