ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

Can I integrate Firebase and ConnectyCube? #162

Closed tahademirer closed 3 years ago

tahademirer commented 3 years ago

I have users in my firebase db. Can I integrate them with ConnectyCube? If I can, how? Thanks!

DaveLomber commented 3 years ago

Yes you can

What you need is to use Custom Identity Provider

As for the start point - please check the following links:

Please let us know if you have any difficulties

You also may find interesting the following issue https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/80

tahademirer commented 3 years ago

Thanks for your quick answer. I'll follow the articles you attached and let you know if I have any other trouble about this.

tahademirer commented 3 years ago

Hi again! I read your documentation and I want to say it's very good! Thanks for your fine work. I have another question. The doc. says that I should enable Firebase Phone Authentication. Can I use E-Mail Authentication instead of Phone? Thank you for your answer. Stay healthy!

DaveLomber commented 3 years ago

If you want to use Firebase E-Mail Authentication instead of Phone then just refer to https://github.com/ConnectyCube/connectycube-reactnative-samples/issues/162#issuecomment-739894218

for this you do not need to enable Firebase Phone Authentication.

tahademirer commented 3 years ago

**Hi again Dave! Sorry for my infinite questions. I'm just a beginner. When I read the doc about "Custom Identity Provider" I realized that some of points are not clear enough for me. This is my Firebase login function which works via React-Redux. I'm using this POST request for verify my users. I want to understand a few things: 1- What should I write to API URL section at my admin panel? Should I write the URL in my POST action below? 2- After ConnectyCube API URL and parameters part is done, what should I do with the token from my database? Should I write a new POST method and send it to ConnectyCube? If it is, Which URL? ( Is https://api.connectycube.com/login enough?)

Thank you!**

`export const login = (email, password) => { return async (dispatch) => { const response = await fetch( "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=[myAPIKey]", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ email: email, password: password, returnSecureToken: true, }), } ); if (!response.ok) { const errorResponseData = await response.json(); const errId = errorResponseData.error.message; let message = "Bir şeyler ters gitti."; if (errId === "EMAIL_NOT_FOUND") { message = "Bu E-Posta ile kayıtlı kullanıcı bulunamadı."; } else if (errId === "INVALID_PASSWORD") { message = "Girmiş olduğunuz şifre hatalı."; } throw new Error(message); } const resData = await response.json();

dispatch({ type: LOGIN, token: resData.idToken, userId: resData.localId });

}; };`

DaveLomber commented 3 years ago

Re 1 - the following should be done:

Re 2 - you should call /login API and pass your user 'email' and 'password' field

tahademirer commented 3 years ago

Dave, you are the best. What a quick support and answer! I'll try it. Thank you!

tahademirer commented 3 years ago

Hi again Dave! Your answer totally worked for me. Amazing! When I publish my app, I'll send you a box of Turkish Delight from Turkey! :) Thanks!