This is awesome! Thank you so much for taking the time of cleaning up the code, this could be the trickiest part sometimes. I loved the way you implemented the completionHandler in SignInAppleHelper, it made me realize that closures are "Reference Type" in Swift 😮, I've been needing this so many times 😅. You definitely stand out compared with the other Swift RUclips Channels.
Thanks a lot for this awesome tutorial! I've been following this playlist for a few videos now and this definitely went over my head at some points. Need to watch the concurrency playlist. Very helpful to see how you deal with problems and your way of debugging errors.
This playlist is very cool. Thank you very much. I ran into a problem, memory leaks, as I understand it. It was worth logging in with Apple, so now the application doesn't even start and xcode writes that it starts consuming too much memory. As I understood it, this is a firebase problem, but the rollback to the old versions did not give any result, alas.
Hy. Is there really no simpler way to login with Apple to Firebase? I love your style, but this is really A LOT. So much going on here . . Thank you! And really grateful for the gists!!! Beautiful!
Thank you, Nick. Very helpful. I've never implemented Sign in with apple as I still don't have a paid developer account.😍 I will watch this again hopefully this year after getting my developer account.
Can Sign In be this complicated? Thanks to this, I learned a lot about swift. This frustrates me, but I have to make money by making apps. Thank you so much.
Awesome video! I followed the whole series and it's amazing! I just wanted to know how can I unwrap the name of the user in apple signin? I can't manage to get the name and set it to the DBUser or print it in any way. Any help? Thank you for your work!
25:31 I asked you regarding displaName on other tutorial, on this function I think should be used OAuthProvider.appleCredential rather than OAuthProvider.credential , but when I changed that I faced this error : Failed: Unable to parse the ID Token.
Haha yea I actually have a mic but I didn’t realize the fan on my computer was going off when recording, so I tried to edit the sound 😭😭😭 I’ve since bought a new MacBook M2 and it’s super quiet 😎
No unfortunately, there’s a SwiftUI way of implementing Apple SSO but it doesn’t work well with Firebase Auth. If they release an easier way, I will 100% replace this video with it
great video but.....just too much for me to consume at this moment. Presentation is very confusing and it's gonna take me couple or triple times to watch this video to get it to work!
@@co-park Firebase automatically persists the authentication. If your UI is putting users back to the login screen, then it’s an issue with your UI code and not Firebase 🤔
@@SwiftfulThinking Are you saying I could do something like: var body: some View { switch Auth.auth().currentUser { case nil: LoginView() default: HomeView() } } And it would persist the user regardless of sign in method? If so, how long do these sessions persist.
Just a heads up: handling Apple's response has changed since the creation of this video (see line of code below). The provider is no longer required, and has been replaced by fullName, which is of type 'PersonNameComponents' 🥴 let credential = OAuthProvider.appleCredential(withIDToken: idTokenString, rawNonce: nonce, fullName: appleIDCredential.fullName)
I ran into a problem when trying to add Sign in With Apple capabilities under signing & capabilities on Xcode. I have also added capability under my app developer profile on the website as well. Have gotten certificates for everything else I needed but am still getting errors for “missing Sign in with Apple” and “missing com.apple.developer.applesignin entitlement.
I don't understand why you are making this so complicated by going at such a length to recreate the whole flow that the SwiftUI Apple Sign In Button provides...? import SwiftUI import AuthenticationServices import FirebaseAuth struct Logins: View { @State var currentNonce = "" var body: some View { VStack { SignInWithAppleButton { request in let nonce = randomNonceString() //Use a function to generate nonce currentNonce = nonce request.requestedScopes = [.email, .fullName] request.nonce = sha256(nonce) //Use a function to SHA256 encrypt } onCompletion: { result in handleAppleSignIn(with: result) } .frame(height: 40) .cornerRadius(8) } } func handleAppleSignIn(with result: Result) { switch result { case .success(let auth): switch auth.credential { case let credential as ASAuthorizationAppleIDCredential: guard let appleIDToken = credential.identityToken else { return } guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else { return } // Initialize a Firebase credential, including the user's full name. let credential = OAuthProvider.appleCredential( withIDToken: idTokenString, rawNonce: currentNonce, fullName: credential.fullName ) // Sign in with Firebase. Auth.auth().signIn(with: credential) { result, error in if let error = error { print(error.localizedDescription) return } // User is signed in to Firebase with Apple. // Continue with your logic } default: print("Error in retrieving auth info") } case .failure(let error): print("Sign in with Apple failed: \(error.localizedDescription)") } } } You can also extract currentNonce and the handleAppleSignIn function into a ModelData Object and pass it through as a environmentObject keep things cleaner.
@@Kuraudo_VII no not yet, ive been looking at the tutorial but at the end i didnt understand all of it. yours seems very short hehe will try it in the next few days. if i run into problems i'll comment here again if you dont mind
func signInApple() async throws { let signInAppleResultsTokens = try await signInAppleHelper.startSignInWithAppleFlow() let authDataResult = try await self.authenticationManager.signInWithApple(tokens: signInAppleResultsTokens) let user = DatabaseUser(auth: authDataResult) try userManager.createNewUser(user: user) } When we tap to signInApple we create "updating" our DB for currect document. It's wrong?
This is awesome! Thank you so much for taking the time of cleaning up the code, this could be the trickiest part sometimes. I loved the way you implemented the completionHandler in SignInAppleHelper, it made me realize that closures are "Reference Type" in Swift 😮, I've been needing this so many times 😅. You definitely stand out compared with the other Swift RUclips Channels.
i miss the intro music but i'm glad you're back with videos
Thanks a lot for this awesome tutorial! I've been following this playlist for a few videos now and this definitely went over my head at some points. Need to watch the concurrency playlist. Very helpful to see how you deal with problems and your way of debugging errors.
Holy Sh*t writing code to sign in with Apple was like we were hacking into the U.S Embassy lol....Great job!
Haha yea it really is! I'm expecting Apple will update the API and I'll have to update this video eventually lol
haha!
Thanks Nick but why it has to be so complex when it comes to the iOS Signin ?
Happy to see you back!!!!!!!🎉
You are legend! Great work👏
This playlist is very cool. Thank you very much. I ran into a problem, memory leaks, as I understand it. It was worth logging in with Apple, so now the application doesn't even start and xcode writes that it starts consuming too much memory. As I understood it, this is a firebase problem, but the rollback to the old versions did not give any result, alas.
Thanks for sharing your high level knowledge, Nick.
Glad it was helpful!
does it matter further lectures if I don't implement appla login here? Well, I wanna pay apple dev account little more later :(
You are a lifesaver that's all i'm saying and I haven't watched the video yet
Enjoy! 🤙🚀
Hy. Is there really no simpler way to login with Apple to Firebase? I love your style, but this is really A LOT. So much going on here . . Thank you! And really grateful for the gists!!! Beautiful!
Thank you, Nick. Very helpful. I've never implemented Sign in with apple as I still don't have a paid developer account.😍 I will watch this again hopefully this year after getting my developer account.
Can Sign In be this complicated? Thanks to this, I learned a lot about swift. This frustrates me, but I have to make money by making apps. Thank you so much.
Awesome video! I followed the whole series and it's amazing! I just wanted to know how can I unwrap the name of the user in apple signin? I can't manage to get the name and set it to the DBUser or print it in any way. Any help? Thank you for your work!
This is awesome! Great content
Fantastic work! Thanks a lot, Nick!
Thanks you so much, you are incredible, that helped me more than you could even think, great great work !
This is amazing. Thank you so much for all the details!
25:31 I asked you regarding displaName on other tutorial, on this function I think should be used OAuthProvider.appleCredential rather than OAuthProvider.credential , but when I changed that I faced this error : Failed: Unable to parse the ID Token.
Great content! Everything but the sound is great. You need a better mic/sound setup. :)
Haha yea I actually have a mic but I didn’t realize the fan on my computer was going off when recording, so I tried to edit the sound 😭😭😭 I’ve since bought a new MacBook M2 and it’s super quiet 😎
@@SwiftfulThinking ahah all right.
Is there a way of doing this without using an UIKit? It seems to create as much trouble as it solves
No unfortunately, there’s a SwiftUI way of implementing Apple SSO but it doesn’t work well with Firebase Auth. If they release an easier way, I will 100% replace this video with it
@@SwiftfulThinking thank you for the reply, great video
Welcome back!
Thanks!!
great video but.....just too much for me to consume at this moment. Presentation is very confusing and it's gonna take me couple or triple times to watch this video to get it to work!
don't bother...There is alternatives for this on RUclips from Kavasoft. He has Sign in with Apple in a single view
Is this code on Github?
Dude I love you
ily2
@@SwiftfulThinking btw, think you could do a vid on persisting apple login for Apple+FirebaseAuth combo? I managed to do it, but doesn't feel right
@@co-park Firebase automatically persists the authentication. If your UI is putting users back to the login screen, then it’s an issue with your UI code and not Firebase 🤔
@@SwiftfulThinking Are you saying I could do something like:
var body: some View {
switch Auth.auth().currentUser {
case nil:
LoginView()
default:
HomeView()
}
}
And it would persist the user regardless of sign in method?
If so, how long do these sessions persist.
do you have this code on github?
Your email is visible at 52:06
Please sign in with facebook
no source code? :/
So handsome
Dude you are really nuking this. You’re making it way more complex than it needs to be. Your code is so complex it’s dumb
Imagine having a senior lead in your team with his mentality. God...his code is so complex and dumb i don't understand why
Just a heads up: handling Apple's response has changed since the creation of this video (see line of code below). The provider is no longer required, and has been replaced by fullName, which is of type 'PersonNameComponents' 🥴
let credential = OAuthProvider.appleCredential(withIDToken: idTokenString, rawNonce: nonce, fullName: appleIDCredential.fullName)
I ran into a problem when trying to add Sign in With Apple capabilities under signing & capabilities on Xcode. I have also added capability under my app developer profile on the website as well. Have gotten certificates for everything else I needed but am still getting errors for “missing Sign in with Apple” and “missing com.apple.developer.applesignin entitlement.
I don't understand why you are making this so complicated by going at such a length to recreate the whole flow that the SwiftUI Apple Sign In Button provides...?
import SwiftUI
import AuthenticationServices
import FirebaseAuth
struct Logins: View {
@State var currentNonce = ""
var body: some View {
VStack {
SignInWithAppleButton { request in
let nonce = randomNonceString() //Use a function to generate nonce
currentNonce = nonce
request.requestedScopes = [.email, .fullName]
request.nonce = sha256(nonce) //Use a function to SHA256 encrypt
} onCompletion: { result in
handleAppleSignIn(with: result)
}
.frame(height: 40)
.cornerRadius(8)
}
}
func handleAppleSignIn(with result: Result) {
switch result {
case .success(let auth):
switch auth.credential {
case let credential as ASAuthorizationAppleIDCredential:
guard let appleIDToken = credential.identityToken else { return }
guard let idTokenString = String(data: appleIDToken, encoding: .utf8) else { return }
// Initialize a Firebase credential, including the user's full name.
let credential = OAuthProvider.appleCredential(
withIDToken: idTokenString,
rawNonce: currentNonce,
fullName: credential.fullName
)
// Sign in with Firebase.
Auth.auth().signIn(with: credential) { result, error in
if let error = error {
print(error.localizedDescription)
return
}
// User is signed in to Firebase with Apple.
// Continue with your logic
}
default:
print("Error in retrieving auth info")
}
case .failure(let error):
print("Sign in with Apple failed: \(error.localizedDescription)")
}
}
}
You can also extract currentNonce and the handleAppleSignIn function into a ModelData Object and pass it through as a environmentObject keep things cleaner.
Cannot thank you enough, saved me an hour. Did a few tweaks and its working like charm 15.2
Brilliant... this is not the only video that he made it very complicated. Sometimes he is very dumb and i don't know why
is this the entire code you used for the apple sign in model?
@@pigreatlor pretty much. But that was a while ago. Are you running into any issues?
@@Kuraudo_VII no not yet, ive been looking at the tutorial but at the end i didnt understand all of it. yours seems very short hehe will try it in the next few days. if i run into problems i'll comment here again if you dont mind
func signInApple() async throws {
let signInAppleResultsTokens = try await signInAppleHelper.startSignInWithAppleFlow()
let authDataResult = try await self.authenticationManager.signInWithApple(tokens: signInAppleResultsTokens)
let user = DatabaseUser(auth: authDataResult)
try userManager.createNewUser(user: user)
}
When we tap to signInApple we create "updating" our DB for currect document. It's wrong?