Thursday, 12 November 2020

Swift Signing User in with Access Group not working

Inside my app I would like to sign in the user using Auth.auth().useUserAccessGroup.

This is my code for signing in with email (user can also sign in with Facebook, Google & Apple):

signUp-Function:

static func signUpWithEmail(email: String, password: String, username: String, finished: @escaping (_ done: Bool) -> Void){
    
    do {
        try Auth.auth().useUserAccessGroup("SN26HDFT24.com.wishlists-app.group")
    } catch let error as NSError {
        print("Error changing user access group: %@", error)
    }
    Auth.auth().createUser(withEmail: email, password: password) { (result, error) in
        
        if let error = error {
            Utilities.showErrorPopUp(labelContent: "Fehler", description: error.localizedDescription)
            finished(false)
        }
        
        if let userId = result?.user.uid { 

             // successfully signed in

        } else {
            print("user couldn't sign in")
            finished(false)
        }
    }
}

Keychain Sharing:

asdf

Problem:

When calling this function if let error = error this fails:

The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered" UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_KEYCHAIN_ERROR, NSLocalizedFailureReason=SecItemCopyMatching (-34018), NSLocalizedDescription=An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered}

so the first time I am calling it, try Auth.auth().useUserAccessGroup("SN26HDFT24.com.wishlists-app.group") actually succeeds, at least it is not throwing anything.

But when calling it again it the do try block fails. With the same error-message as above.

Entitlements:

enter image description here

Capabilities:

enter image description here

I am stuck. Couldn't find anything on this anywhere...



from Swift Signing User in with Access Group not working

No comments:

Post a Comment