ReactNative Google SingIn ด้วย firebase

ReactNative Google SingIn  อันนี้ต่อเนื่องจาก  ReactNative Facebook login ด้วย firebase  ใครยังไม่ได้ สร้าง project firebase และ โหลดไฟล์  google-services.json (สำหรับ android) และ GoogleService-Info.plist (สำหรับ ios) ไปทำตามอันเดิมก่อนนะครับ

1.set keystore’s SHA1 hash ที่ firebase

 

 

2. install lib react-native-google-signin

 

=> ฝั่ง android

อย่าลืมเปลี่ยน compile เป็น implementation นะครับ (android/app/build.gradle)

 

=> ฝั่ง ios

(https://developers.google.com/identity/sign-in/ios/start-integrating)

GoogleService-Info.plist จะมีค่า REVERSED_CLIENT_ID  ให้ copy url เพื่อเอาไปใส่ ใน xcode ตามภาพด้านล่างครับ


 

หลังจาก link จะมีการเพิ่มที่ pod ไฟล์ เข้าไป

pod ‘RNGoogleSignin’, :path => ‘../node_modules/react-native-google-signin’

อย่าลืมสั่ง pod update (เข้าไป cd ios =>สั่ง pod update)

 

3. เพิ่ม googleLogin method เข้าไป ส่วน ui ดูที่  LoginView
(https://rnfirebase.io/docs/v5.x.x/auth/social-auth)

 

 

4. ผลลัพธ์ที่ได้ครับ

video

ส่วนใครจะทำ login facebook อ่านที่บทความ ReactNative Facebook login ด้วย firebase

จบครับ ผิดพลาดขออภัยไว้ ณ ที่นี้ด้วยนะครับ