Firebase SDK and User Registration
Instagram Firebase
Moving on now that we have our registration page setup, we'll go through the very basic steps of setting up our project to include the necessary Firebase frameworks. To be more specific, we'll be installing Firebase Database, Authentication, and Storage to power our Instagram application. Next, we'll go ahead and create a few dummy users with the available input fields inside of our UI. After we confirm that this is working, I'll demonstrate a very useful effect that allows you to show whether or not the registration form is correctly filled out before allowing the user to sign up.

Comments (71)
Krubel Habteyes
6 years ago
I am getting a compiler error that says "Command failed due to signal: Segmentation fault: 11". I have emailed you a screenshot
Brian Voong
6 years ago
Slava Nagornyak
6 years ago
Hi, Brian! Why don't you use !email.isEmpty instead of counting characters? It's shorter
Brian Voong
6 years ago
Sean Moriarity
6 years ago
From iOS 10.0, there is now a .hasText property, so you can use: let isFormValid = emailTextField.hasText && usernameTextField.hasText && passwordTextField.hasText
Hen Shabat
6 years ago
Hi Brian, How do you recommend to deal with unique UserName? Before we complete the registration for new user I want to check for unique UserName. Will we deal with it in the future? Thanks a lot!
Hen Shabat
6 years ago
?
Brian Voong
6 years ago
Hen Shabat
6 years ago
Thank you!
Nathan Hsiao
6 years ago
Hi Brian, Is it a good idea to just get all the users from Firebase, and loop through them to check if username already used?
Brian Voong
6 years ago
omari
6 years ago
Hello Brian. what happens if the user makes a mistake while filling out the form e.g. typing in a not valid email address . How can we help the user and present this in a good and beautiful way in our User Interface ? I mean its not just enough to say if email > 0 ... Thanks
Brian Voong
6 years ago
Stephen Novotny
6 years ago
heres some email validation info: http://swiftdeveloperblog.com/email-address-validation-in-swift/ and here: http://multithreaded.stitchfix.com/blog/2016/11/02/email-validation-swift/ if your using a nodejs backend or googlecloud functio etc you could you use this to check for valid domain etc: https://www.npmjs.com/package/isemail , https://www.npmjs.com/package/email-validator
Dan Boyle
6 years ago
Thanks Brian! Just wanted to put this here incase anybody runs into a similar issue. After I installed Firebase with cocoapods, I got something like 64ish compile warnings. Apparently I installed an older version of Firebase. After running 'pod update' in terminal... all of the warnings went away.
Malikov_Vladimir
6 years ago
Thank you man) GL
omari
6 years ago
Hello Brian, we save the username and profileimageurl of a user in firebase. Why you don't save the password of the user in the tree ? And how do we approach if a user forgets his password. Does it make any sense to save the password of a user in the database ?
Stephen Novotny
6 years ago
firebase docs func confirmPasswordReset(withCode code: String, newPassword: String, completion: @escaping FIRConfirmPasswordResetCallback) https://firebase.google.com/docs/reference/ios/firebaseauth/api/reference/Classes/FIRAuth#-confirmpasswordresetwithcodenewpasswordcompletion
Brian Voong
6 years ago
Stephen Novotny
6 years ago
on UITextField tf.keyboardType = .emailAddress tf.autocapitalizationType = .none can be useful. Brian. Best Tutorials on YouTube including Ray Wenderlich. $50 for this course is extremely good value for money. Thank you.
Brian Voong
6 years ago
Marcelo De Souza
6 years ago
Hi, Brian! A few things seem to have changed on Firebase code. If it might help anyone, here are the necessary modifications for this class: FIRApp -> FirebaseApp FIRAuth -> Auth
jacquesj
6 years ago
Thank you! I was having trouble with this. It looks like the Firebase Pods must have been updated.
gapgag55
6 years ago
+1 Thank a lot
Jake Liu
6 years ago
I have hard time to fix this bug. My App compile ok when it don't have this line of code, but after added that line show this error. Code added button.addTarget(self, action: #selector(handleSignup), for: .touchUpInside) Compile error: (seems like I have other error message, that is why won't compile. ) Command failed due to signal: Segmentation fault: 11 Xcode Version 8.1 beta ---------- Showing those message regardless compiled or not ------------- 2017-06-22 20:44:00.799 Instagram[33808] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb 2017-06-22 20:44:00.815 Instagram[33808] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4001000 started 2017-06-22 20:44:00.816 Instagram[33808] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2017-06-22 20:44:00.817 Instagram[33808] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist 2017-06-22 20:44:00.826 Instagram[33808] <Warning> [Firebase/InstanceID][I-IID017000] Could not determine the app's default Keychain access group (-34018) 2017-06-22 20:44:01.148 Instagram[33808] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled. 2017-06-22 20:44:01.152 Instagram[33808] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled 2017-06-22 20:44:01.167 Instagram[33808] <Error> [Firebase/InstanceID][I-IID009001] Error removing keypair status: -34018 2017-06-22 20:44:01.167 Instagram[33808] <Error> [Firebase/InstanceID][I-IID010007] Unable to remove RSA keypair 2017-06-22 20:44:01.219 Instagram[33808] <Error> [Firebase/InstanceID][I-IID007004] Unable to save checkin info, resetting checkin preferences in memory. 2017-06-22 20:44:01.220 Instagram[33808] <Error> [Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=com.firebase.iid Code=6 "(null)" UserInfo={NSUnderlyingError=0x60800005c470 {Error Domain=com.google.iid Code=-34018 "(null)"}} 2017-06-22 20:44:02.328 Instagram[33808] <Error> [Firebase/InstanceID][I-IID010003] Unable to generate keypair. 2017-06-22 20:44:02.329 Instagram[33808] <Warning> [Firebase/Analytics][I-ACS020001] Failed to get InstanceID: Error Domain=com.firebase.iid Code=-34018 "(null)"
Jake Liu
6 years ago
After I update to the latest XCode 8.3.3 issue is fixed, but still have warning code come up. Looks like some Analytics setting from firebase. Thanks Jake 2017-06-26 13:26:01.227 Instagram[3473] <Warning> [Firebase/Analytics][I-ACS005000] The AdSupport Framework is not currently linked. Some features will not function properly. Learn more at http://goo.gl/9vSsPb 2017-06-26 13:26:01.396 Instagram[3473] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.4001000 started 2017-06-26 13:26:01.786 Instagram[3473] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r) 2017-06-26 13:26:01.863 Instagram[3473] <Notice> [Firebase/Analytics][I-ACS003007] Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist 2017-06-26 13:26:03.471 Instagram[3473] <Warning> [Firebase/Analytics][I-ACS032003] iAd framework is not linked. Search Ad Attribution Reporter is disabled. 2017-06-26 13:26:03.479 Instagram[3473] <Notice> [Firebase/Analytics][I-ACS023012] Firebase Analytics enabled 123
Pavel Bogart
6 years ago
Hello, Brian! When I set the function "button.addTarget(self, action: #selector(hadnleSignUp), for: .touchUpInside)" I am getting an error "Argument of '#selector' refers to instance method 'handleSignUp()' that is not exposed to Objective-C" When I expose the func handleSignUp and add '@objc' as recommended by Xcode 9 The console log doesn't show my print statement when I press "Sign Up" button. Thank you for your great tutorials! ✌️
Fabio Giolito
6 years ago
I have this same issue '@objc' before the function fixed it for me but I'd like to understand why is that needed? Is there a better/newer way to do this in swift?
Pavel Bogart
6 years ago
I've figured out my problem. It's important to say that I am using Xcode 9 and Swift 4 accordingly. As you said to avoid some trash logs in the console need to add a command "OS_Activity_Mode - disable". When I add this line I get few problems: 1. When I launch the app there happens a bug. Application appears and disappears multiple amount of times 2. When I press SignUp Button nothing appears in the console log. To tackle the issue you just don't need to add the command "OS_Activity_Mode - disable" And as well to make a function "handleSignUp" work you need to add @objc before the word 'func handleSignUp' In that case everything will be working fine :)
Brian Voong
6 years ago
davidc
6 years ago
For anyone who is having trouble at 15:20 with gaurd not working. You have to enable it in the Edit Scheme -> Run -> Diagnostics enable "Gaurd Malloc"
amukasa
6 years ago
Hello, Another way to check for the text in the textField is by using the isEmpty method instead of characters.count. func handleTextInputChange(){ guard let isEmailValid = emailTextField.text else {return} if isEmailValid.isEmpty { signUpButton.backgroundColor = UIColor.rgb(149, green: 204, blue: 244) } else { signUpButton.backgroundColor = .red } } Otherwise, I'm already enjoying the lessons so far and I like mostly like how straight to the point you are. Thank you.
angeloCEO
6 years ago
I have a problem when it come to my terminal it's not setting up like yours show me. and I had this problem from previous app that I try to build using my terminal. can you please help me
angeloCEO
6 years ago
How your terminal automatically shows " Brians-MacBook-Pro: InstagramFirebase brianvoongs$ "?​
Brian Voong
6 years ago
angeloCEO
6 years ago
how to do that please?
Brian Voong
6 years ago
angeloCEO
6 years ago
As much I wanna build this app with you this terminal part have me confuse and going crazy I already watch a lot of video's on youtube about terminal and try to follow but none of them satisfy my needs...but I'm not quitting
angeloCEO
6 years ago
I got it everything is good with a terminal after a lot of research, actually of your video on youtube help me out, I dedicate myself to finish this course with a clear understand... Thanks for always reply you the best bro
Brian Voong
6 years ago
angeloCEO
6 years ago
In line 13:42 "FIRAuth.auth()?.createUser(withEmail: email, password: password, completion: { (user: FIRUser?, error: Error?) in FIRAuth and FIRUser are giving me a problem I thought the were Firebase I put FirebaseAuth and FirebaseUser they still giving me a problem. What can I do, ​please
Justin Rose
6 years ago
Hey Brian, I have had a little trouble with the code shown below. Xcode is telling me this " Value of type 'StorageReference' has no member 'put' " let filename = NSUUID().uuidString Storage.storage().reference.().child("profile_images").child(filename).put(uploadData, metadata: nil, completion: { (metadata, err) in Thanks, Justin
Brian Voong
6 years ago
fabien040
6 years ago
Hi Brian - it seems that Firebase API has changed. For example instead of FIRAuth.auth.. it is now Auth.auth(.. cheers
angeloCEO
6 years ago
I have that same problem too.
Clive Wong Toh Soon
6 years ago
How do I disable the text field from being auto capitalising the first character?
smiller193
6 years ago
Is anyone having an issue with the input accessory view getting stuck at the bottom? When exiting comment screen
Chard
6 years ago
how to verify Eamil format ~~ lalalala
stonypig1
6 years ago
hello , can you add a lesson for phone registering , it is new feature from firebase, it is so cool, and most app has it for registering user these days. thanks
Tube
5 years ago
I had a lot of trouble getting XCode to find and recognize the GoogleService-Info.plist. It complained it couldn't find a valid one. I tried installing it by drag-and-drop and Add Files... Finally, I guess, I got the right combination of add technique and add options. Wish I could tell you what it accepted.
Brian Voong
5 years ago
Tube
5 years ago
Well, Xcode 9 finally accepted (found) it, but I tried so many things I can't tell you which one succeeded. It might have mattered where the file was physically. Oh, I look in my trash can and find files named "GoogleService-Info 16-29-20-652.plist", "GoogleService-Info 4.05.43 PM.plist", etc. which I think had already been imported into Xcode. Anyway, I am up and running again now.
Adam El-Kadi
5 years ago
Guys I know how to fix the problem... So 1. Go to your project settings 2. Press on Build Phases 3. Press on Copy Bundle Resources 4. Drag the your GoogleServices-Info.plist into there... And that should solve it!
Adam El-Kadi
5 years ago
Btw this problem is for people who are getting THREAD 1 (stuff), it is because your xcode project cannot find the .plist you just downloaded. Do as I did and it should work
albaqawi
5 years ago
LOVE YOU ADAM! This was a living nightmare for me with even the Firebase chat app earlier I learn something lifesaving today :D Works perfectly
Adam El-Kadi
5 years ago
My pleasure man :)
Adam El-Kadi
5 years ago
Guys heads up, I ran into many problems since I have Swift 4. Just use the project file, before it wasn't able to register users now after I looked at how he did it works... Thank you bro
Beyond2021
5 years ago
Simply Awesome! Swift4
timboehm
5 years ago
Hmmm, I've tried to do this lesson 3 times now and each time I get the same issue in Xcode. I try to build and run the app and the console says this: 2017-10-12 13:57:09.596150-0400 LifeStyleNow.V2[4843:459102] [MC] Lazy loading NSBundle MobileCoreServices.framework 2017-10-12 13:57:09.597134-0400 LifeStyleNow.V2[4843:459102] [MC] Loaded MobileCoreServices.framework 2017-10-12 13:57:09.600654-0400 LifeStyleNow.V2[4843:459102] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/timboehm/Library/Developer/CoreSimulator/Devices/93DD3AE8-9841-470D-A8BB-E5DCC4ECBD31/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2017-10-12 13:57:09.627507-0400 FirebaseInstagam[4843:459254] [Firebase/Core][I-COR000012] Could not locate configuration file: 'GoogleService-Info.plist'. 2017-10-12 13:57:09.628398-0400 FirebaseInstagam2[4843:459254] [Firebase/Core][I-COR000005] No app has been configured yet. 2017-10-12 13:57:09.656063-0400FirebaseInstagam[4843:459102] *** Terminating app due to uncaught exception 'com.firebase.core', reason: '`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find a valid GoogleService-Info.plist in your project. Please download one from https://console.firebase.google.com/.' *** First throw call stack: I have made sure to do the pod install correctly and verify from exactly what you do on the video. I can look right at the Xcode IDE and see the GoogleService-Info.plist in the left margin as you placed it in the video. Do you have any suggestions on what I can do at this point?
Ashim Dahal
5 years ago
The plist GogleService-Info.plist might not have been added correctly even it's showing up in the file menu. You can delete the previous plist and add a new one as shown in the tutorial... that might help. I think for the Xcode to recognize the file properly it needs to add a file to its directory, and not copy and paste into​ the repository. I hope this helps.
timboehm
5 years ago
okay hold on. Disregard my comment below. I saw what Adam El-Kadi wrote and followed his advice to add to the 'Copy Bundle Resources' area in Build Phases from the Project view.
Zhao Peng Gang
5 years ago
can everyone tell me how to solve the 1. Thread 1: signal SIGABRT ??? (after import firebase and run the app the simulator shows a blank screen) 2. leveldb-library 3 issues ??? ..... Thanks
Brian Voong
5 years ago
faraaz
5 years ago
This video is outdated: the static instance 'FIRAuth' is depreciated, instead use 'Auth'
Brian Voong
5 years ago
Vijay Bhatter
5 years ago
I would suggest if you could either mention the changes in Swift 3 - Swift 4 in the description or provide a link to the changes so that its easier to follow while watching the tutorial. As many times we do not need to download the project unless any file needs to be added to the asset library. Can we also add Facebook / Twitter social media logins to this app as it will make this course even more useful and complete.
Brian Voong
5 years ago
Alex Alx
5 years ago
You're the best instructor I have seen so far. Good job Brian!
nombienombie
5 years ago
Simply brilliant. I've learned more in a few 20 minutes then I have with countless hours on other tutorials.
roi1672
5 years ago
For anyone using Swift 4, ".characters" is depreciated as of Swift 4, so for example, instead of typing, password.characters.count => try password.count Strings is a collection of characters as of swift 4
arum seo
5 years ago
thank you!
Tokyojogo
5 years ago
Hi Brian, I have a question. Are you gonna move the handleSIgnUp later on to a dataservice file and use singleton? I don't want to jump the gun but if its not included, I would like to know the best way to connect to Firebase and also, manage all the code (dataservice).
Brian Voong
5 years ago
Brian Voong
5 years ago
Tokyojogo
5 years ago
Thank you. I'll wait 'til I get to that episode... Great work man!
Michael Evans
5 years ago
i had to import FirebaseAuth to get the project to build. Anyone else?
rebeloper
5 years ago
No. You should import Firebase and than use the following syntax to create anew user: Auth.auth().createUser(withEmail: email, password: password) { (user, error) in // ... } see docs here: https://firebase.google.com/docs/auth/ios/password-auth
rebeloper
5 years ago
No. You should import Firebase and than use the following syntax to create anew user: Auth.auth().createUser(withEmail: email, password: password) { (user, error) in // ... } see docs here: https://firebase.google.com/docs/auth/ios/password-auth
Michael Evans
5 years ago
If I only import Firebase, it doesn’t recognize Auth. Same happened for Database when I tried to call Database.database(). Gave me an unresolved identifier issue. I imported Database and everything works like Brian’s. not sure if there is something missing in the pod File?
rebeloper
5 years ago
Interesting... Have you updated your pods with: pod update ?
DerekRM
5 years ago
I wish I would have read your comments before getting stuck on this for a little while. Didn't see this comment till about 5 minute after becoming unstuck
corbinyo
5 years ago
What worked for me: 1) open Podfile in command line 2) add pod 'Firebase/Auth' to podfile. save and exit. 3) run pod update in command line. 4) use this code: Auth.auth().createUser(withEmail: email, password: password, completion: { (user: User?, error: Error?) in if let err = error { print("Failed to create user:", err) return } print("Successfully created user:", user?.uid ?? "") }) }
Sanket Ray
5 years ago
Hey Brian, I have this weird problem...Every single app that i create is always of huge size...just after completing the first two episodes, my app size is 35 MB...do you know what may be causing this?
Brian Voong
5 years ago
nexie
5 years ago
The Identifier field in firebase does not register e-mail... :( as per new rules of Facebook. So what can I do? Here is a pastebin in swift3 for you: https://pastebin.com/QXtd8Nti Please let me knoe if there's a better solution to put something (anything) in the Identifier field. Thanks.
ottogutierrez
5 years ago
Hello Brian, I'm trying to install the pods on the project. However, once I install it and open the workspace and try to build, i get a lot of warnings https://imagebin.ca/v/3rr7Vq6S8eRG Do you know why this is happening? Thanks!
Brian Voong
5 years ago
ottogutierrez
5 years ago
Thanks Brian!
Hans Rietmann
5 years ago
你好Brian, 首先感谢你提供的课程。我是初学者,有个问题已经困扰我两天了, 当在终端执行sudo gem install cocoapods,返回ERROR: Could not find a valid gem 'cocoapods' (>= 0) in any repository。 当执行pod init, 返回[!] Existing Podfile found in directory。 当执行pod install时,返回[!] Invalid `Podfile` file: undefined method `Pod' for #<Pod::Podfile:0x007fa930aa2d38>. # from /Users/taliazhang/Desktop/InstagramFirebase/Podfile:10 # ------------------------------------------- # > Pod 'Firebase/Auth' # Pod 'Firebase/Database' # ------------------------------------------- 我也重新安装过macOS,看别的安装说明,不知道为什么不行,请你帮帮我,谢谢!
Brian Voong
5 years ago
Jubal Thang
5 years ago
Hi, can you help me please? I got this error when I try to install pod " pod init" I have Xcode 9.3 (9E145) ――― MARKDOWN TEMPLATE ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ### Command ``` /usr/local/bin/pod init ``` ### Report * What did you do? * What did you expect to happen? * What happened instead? ### Stack ``` CocoaPods : 1.4.0 Ruby : ruby 2.3.3p222 (2016-11-21 revision 56859) [universal.x86_64-darwin17] RubyGems : 2.5.2 Host : Mac OS X 10.13.4 (17E199) Xcode : 9.3 (9E145) Git : git version 2.15.1 (Apple Git-101) Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib Repositories : master - https://github.com/CocoaPods/Specs.git @ e42369b6cdfaead2efc616493a73761de6439103 ``` ### Plugins ``` cocoapods-clean : 0.0.1 cocoapods-deintegrate : 1.0.2 cocoapods-plugins : 1.0.0 cocoapods-search : 1.0.0 cocoapods-stats : 1.0.0 cocoapods-trunk : 1.3.0 cocoapods-try : 1.1.0 ``` ### Error ``` RuntimeError - [Xcodeproj] Unknown object version. /Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.4/lib/xcodeproj/project.rb:217:in `initialize_from_file' /Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.5.4/lib/xcodeproj/project.rb:102:in `open' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.4.0/lib/cocoapods/command/init.rb:41:in `validate!' /Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:333:in `run' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.4.0/lib/cocoapods/command.rb:52:in `run' /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.4.0/bin/pod:55:in `<top (required)>' /usr/local/bin/pod:22:in `load' /usr/local/bin/pod:22:in `<main>' ``` ――― TEMPLATE END ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― [!] Oh no, an error occurred. Search for existing GitHub issues similar to yours: https://github.com/CocoaPods/CocoaPods/search?q=%5BXcodeproj%5D+Unknown+object+version.&type=Issues If none exists, create a ticket, with the template displayed above, on: https://github.com/CocoaPods/CocoaPods/issues/new Be sure to first read the contributing guide for details on how to properly submit a ticket: https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md Don't forget to anonymize any private data! Looking for related issues on cocoapods/cocoapods... - RuntimeError - [Xcodeproj] Unknown object version. https://github.com/CocoaPods/CocoaPods/issues/7458 [closed] [6 comments] 6 hours ago - RuntimeError - [Xcodeproj] Unknown object version. https://github.com/CocoaPods/CocoaPods/issues/6992 [closed] [10 comments] a day ago - RuntimeError - [Xcodeproj] Unknown object version. https://github.com/CocoaPods/CocoaPods/issues/6991 [closed] [11 comments] 03 Feb 2018 and 30 more at: https://github.com/cocoapods/cocoapods/search?q=[Xcodeproj]+Unknown+object+version.&type=Issues&utf8=✓
Brian Voong
5 years ago
Jubal Thang
5 years ago
Update Ruby fixed it. Thank you.
Akiya Ozawa
5 years ago
Hi Brian and Jubal, Thanks for pointing out the issue of Ruby and Cocoapods installation. For those who haven't updated the new version, you will not see the xcworkspace file. So make sure to update it by typing the command below in your terminal $ sudo gem install cocoapods --source http://rubygems.org Hope this helps!
tetraprism95
5 years ago
Hey Brian, ever since I transferred from normal xcode project file to xcworkspace and ran the simulator, for some reason I think the stackView's height decreased or got squished. So, I tried changing the height from the anchor() function but it does nothing. Any reason why this is?
tetraprism95
5 years ago
Nevermind, I found what it was. In the extension UIView, I didn't setActive to true for width and height. IDK HOW I missed that.
jayrsonani
5 years ago
Hey Brian, when is user email.characters.count > 0 so i error this despeted "characters" so what can i do..
pawelcichonski
5 years ago
email.count > 0
Gabriel Seben
5 years ago
Hello I would like to know how to make an image on the plus button, the image being in firebase   if (self.user? .profileImageUrl.isEmpty)! {                  self.plusPhotoButton.setImage (#imageLiteral (resourceName: "plus_photo"), for: .normal)              } else {                  self.plusPhotoButton.setImage (self.user? .profileImageUrl, for: .normal)              } I'm using this, but "self.user? .profileImageUrl" is wrong How can I use the image url to set the plusButton image? Thank you
Brian Voong
5 years ago
AlfieLBTA
5 years ago
Hey Brian, this course is looking awesome, learning a lot from your leassons, you really have a nice way of teaching. I was wondering if in later videos you include the scroll view into the registration/login page , and if not what do your recommend better: inserting everything into a scroll view or just moving up the add picture button top margin?
fendypierre
5 years ago
  Auth.auth()?.createUser(withEmail: email, password: password, completion: { (user: User?, error: Error?) in             if let err = error{                 print("Failed to create user:",err)             }             print("Successfully created user:", user?.uid ?? "")                      }) When trying to implement this code, I keep getting the error below regarding the ? . Any idea on how to resolve ? Cannot use optional chaining on non-optional value of type 'Auth'
fendypierre
5 years ago
I would share a print screen but no images are allowed in the comment section. My code is basically identical to yours.
fendypierre
5 years ago
update: I resolved the issue. A lot of the functions and methods were renamed since you updated the tutorial. But now I'm having more issues. Nodes arent being created in the database and I'm unsure as to why. here is a snippped of my code: let filename = NSUUID().uuidString Storage.storage().reference().child("profile_images").child(filename).putData(uploadData, metadata: nil, completion: { (metadata, error) in if let err = error { print("Failed to upload profile image:", err) return } print("Successfully uploaded profile image:", metadata!) guard let profileImageUrl = Auth.auth().currentUser?.photoURL?.absoluteString else { return } print("Successfully uploaded profile image:", profileImageUrl) guard let uid = Auth.auth().currentUser?.uid else { return } let dictionaryValues = ["username": username, "profileImageUrl": profileImageUrl] let values = [uid: dictionaryValues] Database.database().reference().child("users").childByAutoId().setValue(values, withCompletionBlock: { (err, ref) in if let err = err { print("Failed to save user info into db:", err) return } print("Successfully saved user info to db:",uid) })
Deniz Mersinlioglu
5 years ago
Hi fendypierre, You can use this handleSignUp function in updated versions of firebase and swift: @objc func handleSignUp(){ guard let email = emailTextField.text, !email.isEmpty, let username = userNameTextField.text, !username.isEmpty, let password = passwordTextField.text, !password.isEmpty else {return} Auth.auth().createUser(withEmail: email, password: password) { (result: AuthDataResult?, error: Error?) in if let error = error{ print("fail to create user:", error) return } print("Succesfull adding user", result?.user.uid ?? "") } }
p31d3ng
5 years ago
`guard let email = emailTextField.text, !email.isEmpty else { return } ` could make it simpler :)
Brian Voong
5 years ago
p31d3ng
5 years ago
what a blazing fast reply! it's awesome to know everything's up to date! thanks for your effort.
Deniz Mersinlioglu
5 years ago
Hi p31d3ng and Brian, This single guard let method will be more straight forward: guard let email = emailTextField.text, !email.isEmpty, let username = userNameTextField.text, !username.isEmpty, let password = passwordTextField.text, !password.isEmpty else {return}
p31d3ng
5 years ago
Hi Deniz, Personally, I would avoid doing so because there's no explicit logical operator present. (&& or || ) Maybe because I came from other programming languages and there's no guard statement :)
Deniz Mersinlioglu
5 years ago
Hi Brian, You can use this function to handleTextInputChange, I think it is a little shotcut :) @objc func handleTextInputChange(){ let isFormValid = !(emailTextField.text?.isEmpty)! && !(userNameTextField.text?.isEmpty)! && !(passwordTextField.text?.isEmpty)! signUpButton.isEnabled = isFormValid signUpButton.backgroundColor = isFormValid ? UIColor.rgb(red: 17, green: 154, blue: 237) : UIColor.rgb(red: 149, green: 204, blue: 244) } Thanks,
Brian Voong
5 years ago
chasekling
5 years ago
Hi Brian, Loving the course so far. Can you pleas explain how this works: "guard let email = emailTextField.text, !email.isEmpty else { return }" I'm specifically confused why you assign both emailTextField.text and then !email.isEmpty. I understand it's a validation process, but why have the two values separated by a comma?
chasekling
5 years ago
Please ignore my question. Continued to watch the video and found the answer.
Fayomi
5 years ago
Hello, I love all your courses and have already purchased the Kindle and Core data one (both excellent) Right now i'm going through your free chat building app on youtube and got stuck on saving the new user data to firebase (as with the new firebase and swift 4 the syntax seems to have changed a lot). Will this course include how to save users to firebase using the new syntax?
austinj95
5 years ago
Hey, Brian! After pod install and opening the 'xcworkspace' file to continue with the project, I run the app in the simulator and get this message in my console: 2018-07-16 10:11:25.507365-0500 InstagramFirebase[26606:11059369] 5.4.0 - [Firebase/Core][I-COR000022] Firebase Analytics is not available. any ideas as to why this is happening? Thank you!
hs.heunseuk
5 years ago
Hey Brian, I did all the things with the pod install stuff. But at the end i got Firebase Analytics is not available. What should i do next? Thankyou!
austinj95
5 years ago
If anyone is having issues with the handleTextInputChange function since member 'characters' has been deprecated, here is what I did which seems to work fine. @objc func handleTextInputChange() { let isFormValid = emailTextField.text?.isEmpty == false && usernameTextField.text?.isEmpty == false && passwordTextField.text?.isEmpty == false if isFormValid { signUpButton.backgroundColor = UIColor.rgb(red: 17, green: 154, blue: 237) } else { signUpButton.backgroundColor = UIColor.rgb(red: 149, green: 204, blue: 244) } }
Ling Vu
5 years ago
The characters attribute is deprecated. Instead you can write count without characters like email.count
Om Bhagwan
5 years ago
Hi Brian , I am getting Error when I am trying to register . Auth.auth().createUser(withEmail: email, password: password) { (user:User?, error:Error?) in } Can you give me some idea how to fix this ?
Brian Voong
5 years ago
Slava Nagornyak
5 years ago
You are not receiving User in response now, you receive Result entity which contains user field. Hope it helps
Ling Vu
5 years ago
The syntax for the completion handler has changed. Which means that your code snippet of createUser should be like Auth.auth().createUser(withEmail: email, password: password) { (user: AuthDataResult?, error: Error?) in if let err = error { print("Failed to create user:", err) return } print("Successfully created user:", user?.user.uid ?? "") } Now it should run perfectly fine. At least i hope so.
Tayo Willie Fatimehin
5 years ago
Thank you Ling
isymfs
5 years ago
This course is out of date. Following along by video is frustrating. Please remake the videos or charge less for the course.
Brian Voong
5 years ago
hs.heunseuk
5 years ago
Hey Brian, I did all the things with the pod install stuff. But at the end i got Firebase Analytics is not available. What should i do next? Thankyou!
seventhaxis
5 years ago
re: @hs.heunseuk The reason the Analytics service is unavailable is because Brian demonstrated how to selectively add elements of the SDK to the app (i.e. Authentication, Database, and Storage).
hs.heunseuk
5 years ago
Hi! So what do you suggest to make the project connected with firebase? Because i am still learning :) thankyou!
seventhaxis
5 years ago
Add 'Firebase/Core' to your podfile and then do a pod install.
fkeebie
4 years ago
I share the same feeling with you. When I did the free video tutorials, I learned a lot from "deciphering code differences". That is true when I follow along this video tutorial. I am learning from 'deciphering' more than just from writing codes as instructed in the video.
hs.heunseuk
5 years ago
Hey Brian, I did all the things with the pod install stuff. But at the end i got Firebase Analytics is not available. What should i do next? Thankyou!
oversphere
5 years ago
try googling "Swift Firebase Analytics not available", you'll probably find an answer
Binary_Jackson
4 years ago
Maybe just insert this into your Podfile -> pod 'Firebase/Core' Then run inside your path -> pod install
Fares
5 years ago
Command failed due to signal: Segmentation fault: 11 error ??
Brian Voong
5 years ago
dclawson
5 years ago
I'm working on this, mid September 2018. I'd recommend going to your Firebase Console, clicking on the documentation (docs) in the upper-right, and then going to the iOS section. They have code snippets. I figure it's good for me to learn to go to the docs and learn directly how to get the syntax you need for a service that's continually evolving.
beto123
5 years ago
Hi Brian! Great stuff.
beto123
4 years ago
I can't write to the database. I get this error message. Failed to save user info into database: Error Domain=com.firebase Code=1 "Permission denied" UserInfo={NSLocalizedDescription=Permission denied} Can anyone help. I installed 'firebase/core' already
Brian Voong
4 years ago
beto123
4 years ago
Ok Thank You Very Much! I fixed the problem.
Shehryar Bajwa
4 years ago
Hey how did you resolve this issue? I am having a similar problem
Chintan
4 years ago
Has a solution been posted?
nickmohara
4 years ago
Hi Brian - Can you point me to some documentation that would allow me to "link" multiple accounts like IG currently has? I've already built out the UI but am just wondering what the best practices are to handle the back end for linking accounts. Firebase doesn't seem to support this. Thanks!
roygbiv
4 years ago
@ 17:30 Hi Brian, can I use this instead ? Will that cause any problems i may not be aware of ? Thanks ! guard let email = emailTextField.text, email.description.count > 0 else { return }
Brian Voong
4 years ago
ncytimothy
4 years ago
Hi roygbiv, looking at the Apple documentation, it appears that the usage of this variable is discouraged. From Apple: "Using this property directly is discouraged. Instead, use simple assignment to create a new constant or variable equal to this string." https://developer.apple.com/documentation/swift/string/2431307-description
roygbiv
4 years ago
@25:30 Hi Brian, can i just use signUpButton.isEnabled = true under @objc func handleSignUp() instead of having to put it under func handleTextInputChange ? @objc func handleSignUp() { guard let email = emailTextField.text, email.description.count > 0 else { return } guard let username = usernameTextField.text, username.description.count > 0 else { return } guard let password = passwordTextField.text, password.description.count > 0 else { return } signUpButton.isEnabled = true
Hsuen
4 years ago
hi Brian, how do you handle weak password when tapped sign up button, as it cover with a yellow background and disable to delete the text. Thanks
ncytimothy
4 years ago
Hi Brian, love the tutorials, thank you! However, I have always wondered about privacy & security if I were to push the project to GitHub. My first instinct is that I would gitignore the GoogleServices-Info.plist file, but would there be any other way to protect myself if I push to project to GitHub as a public repo?
Copytan
4 years ago
Howdy Brian, Xcode is saying .characters is deprecated. Is there updated syntax that you can show? @objc func handleTextInputChange() { let isEmailValid = emailTextField.text?.characters.count ?? 0 > 0 //This is where the problem is if isEmailValid { signupButton.backgroundColor = .red } else{ signupButton.backgroundColor = UIColor.rgb(red: 149, green: 204, blue: 244) } } Thanks.
Brian Voong
4 years ago
lxirsh
4 years ago
I haven't looked at Brian's solution, but I just used the isEmpty method. You'll need to unwrap the text first. Ex g: guard let email = emailTextField.text, !email.isEmpty else { // do stuff return }
timothyryu
4 years ago
You can just take “.characters” out. The “.characters” was deprecated and is now unnecessary. It will work if you just say: emailTextField.text?.count ?? 0 > 0
Dino32
4 years ago
Brain hi! Please help, I can't init pod. Do everything like you say in video. Air-Dmitrij:~ dmitrypapusin$ cd /Users/dmitrypapusin/Desktop/Дмитрий/SwiftCodes/Swift\ Course/MySocialNet/MySocialNet Air-Dmitrij:MySocialNet dmitrypapusin$ pod init [!] No Xcode project found, please specify one Air-Dmitrij:MySocialNet dmitrypapusin$
Dino32
4 years ago
sorry) I solve the problem)
RayBee
4 years ago
At the end of lesson 49, will be this app be complete to the point I can submit it to the App Store?
MaxApp
4 years ago
Hey Brain, in the updated version you used let isFormValid = emailTextField.text?.isEmpty != true && usernameTextField.text?.isEmpty != true && passwordTextField.text?.isEmpty != true != true does it matter if you use == false or no Thanks Brain
MaxApp
4 years ago
instead of this != true
valdezr
4 years ago
I don't think it would matter. It should produce the same results.
MaxApp
4 years ago
Thank you! I figured that along time ago!
khalid.usa2017@gmail.com
4 years ago
Hi Brian Thank you for everything you are doing, I just want to know if it is possible to download your videos on my desktop
Clint Larenz Nurse
4 years ago
Trying to check if username is taken or not... I keep getting " Username does not exist" even when I add a username that is taken. Do you see something wrong here? // TODO check if username is already taken in the database let reference = Database.database().reference().child("users") reference.child("username").observeSingleEvent(of: .value, with: { (snapshot) in if snapshot.exists() { print("Username already exists") } else { print("Username doesn't already exist") } }, withCancel: nil)
jc4883
4 years ago
Hiyah ! Could you explain this line in your code? isFormValid = emailTextField.text?.count ?? 0 > 0 so is .count an integer if it is not nil and false otherwise?
valdezr
4 years ago
This is how I'm interpreting that line: First, it checks if the emailTextField.text exists. Next,`count ?? 0 > 0` I think is the same as `count != nil ? count! : 0`. Meaning that if count does have value, then isFormValid will store its value and if count is nil, then it will be 0. Not 100% sure about this, because I don't really get the purpose of the `0 > 0`, and still new to the nil coalescing operator (`??`), but hope this helps nonetheless.
valdezr
4 years ago
Correction^ I think I was wrong in my prior explanation. Here's what I'm pretty sure is happening: I think it's best to think about like this first: int myTextCount = emailTextField.text?.count ?? 0 bool isFormValid = myTextCount > 0 Since emailTextField.text is optional, we have two cases to consider: 1. emailTextField.text is nil . -> myTextCount = 0 2. emailTextField.text is not nil . -> myTextCount = emailTextField.text.count Then isFormValid will either be 1 or 0 (true or false) dependent on what myTextCount is.
Chad-michael Muirhead
4 years ago
how can i make it that the password and email that i store for the user are hidden from ME . i dont want to be able to see all my users private info but want to still be able to manage and retrive and fetch
valdezr
4 years ago
I think Firebase runs a hash on the password automatically: https://firebaseopensource.com/projects/firebase/scrypt/ Regarding a hidden email, Firebase seems to support several different types of authentication: https://firebase.google.com/docs/auth/?authuser=0. `Custom auth system integration` and the `Anonymous auth` are two options which may be a better fit for your needs. Another solution could be to hash the email that you store into Firebase's email field then proceeding to read/write user data by decrypting/encrypting their credentials...but that will probably add quite a few hurdles to your project.
Jp1478
3 years ago
Should I be worried if after I’m my editor scheme I added the disable for activity mode and nothing popped up but firebase is already installed
tekgeek1
2 years ago
What is causing the @objc to have to be used?
HELP & SUPPORT