ConnectyCube / connectycube-js-sdk-releases

Releases materials for ConnectyCube JS SDK platform https://connectycube.com
9 stars 1 forks source link

Android side not working and same code is working for IOS in react native #108

Open GimmeForeDev1 opened 2 years ago

GimmeForeDev1 commented 2 years ago

I am working in React native , when User sign up in android side at that time i'm getting catch block with error of "User not found" but when i sign up via IOS device i am not getting error and successfully sign up and chatting with user . Please give some solution for this

DaveLomber commented 2 years ago

Can you post a code snippet how you do a login

GimmeForeDev1 commented 2 years ago

Looping in the developers.

Jigar/Rashmi, Can you send them what is needed? Jameson

On Fri, Jul 1, 2022 at 3:37 AM 'Dave Pol Lomber' via Developers < @.***> wrote:

Can you post a code snippet how you do a login

— Reply to this email directly, view it on GitHub https://github.com/ConnectyCube/connectycube-js-sdk-releases/issues/108#issuecomment-1172091664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYK432ZSBPU2A7IE3CNVOJLVR2U43ANCNFSM52IIAZTQ . You are receiving this because you authored the thread.Message ID: @.*** com>

GimmeForeDev1 commented 2 years ago

Hi Team 

We have resolved this with custom logic, but thank you for all your support 

Thank you,

Kushal M 

---- On Fri, 01 Jul 2022 17:44:51 +0530 Customer Support @.***> wrote ---

Looping in the developers.

Jigar/Rashmi,

Can you send them what is needed?

Jameson

On Fri, Jul 1, 2022 at 3:37 AM 'Dave Pol Lomber' via Developers @.***> wrote:

Can you post a code snippet how you do a login

— Reply to this email directly, https://github.com/ConnectyCube/connectycube-js-sdk-releases/issues/108#issuecomment-1172091664, or https://github.com/notifications/unsubscribe-auth/AYK432ZSBPU2A7IE3CNVOJLVR2U43ANCNFSM52IIAZTQ. You are receiving this because you authored the thread.

GimmeForeDev1 commented 2 years ago

Hello , Please find below code which we have implemented in React native

--> Signup.js

const User_signup_connectycube = (data) => { console.log("data signup chat" , data ) const userProfile = { password: ConnectyCubeConstent.Password, email: data.email, login: data.email, }; console.log("chat ==>" , userProfile) ConnectyCube.createSession() .then((session) => { ConnectyCube.users .signup({ ...userProfile, ...session }) .then(async (user) => { console.log("user connectyCube", user) await AsyncStorage.setItem('ConnectyCubeUser', JSON.stringify(user)); }) }) .catch((error) => { console.log("catch in complete profile" , error) }); }

--> login.js

Called this event on press of login button EventRegister.emitEvent(EventsNames.USER_LOGIN, "user login"); // send event to app.js to start updating location

--> App.js

componentDidMount() { setTimeout(() => SplashScreen.hide() , 300);

EventRegister.addEventListener(EventsNames.USER_LOGIN, (data) => {
  console.log("EventRegister.addEventListener(EventsNames.USER_LOGIN, (data) => {");
  this.initalizeConnectyCube();

});
 this.AppStateChangeSubscription = AppState.addEventListener("change", this._handleAppStateChange);
}

 async initalizeConnectyCube() {
console.log("async initalizeConnectyCube() {");
// await this.checkPermission();

const {CREDENTIALS,CONFIG,Password} = ConnectyCubeConstent;
ConnectyCube.init(CREDENTIALS,CONFIG);

const login = await AsyncStorage.getItem('ConnectyCubeUser').then((u) => {
  //return JSON.parse(u).user.email
  console.log("user object " , u)
  console.log( {ConnectyCubeUser:u})
  console.log(typeof u)
  return JSON.parse(u)?.user?.email || JSON.parse(u)?.email 
});

console.log("user app" , await AsyncStorage.getItem('ConnectyCubeUser'));

const userCredentials = {
  login: this.state.userEmail,
  password: Password,
};

await ConnectyCube.createSession(userCredentials)
  .then((session) => {
    console.log("session" ,session)
    // SessionManager.setConnectyCubeUserSession(session);
    const userLoginCredentials = {
      email: this.state.userEmail,
      password: Password,
    };
    console.log("createSession -> ",session)
    return ConnectyCube.login(userLoginCredentials);
  })
  .then(async (user) => {
    console.log("login -> ",user)

    // await this.createPushListener();
     await this.subscribeToPushNotification();
    return ConnectyCube.chat.connect({
      userId: user.id,
      password: Password,
    });
  })
  // .then(this.userProfileUpdate)
  .catch((e)=>{
    console.log(".catch((e)=>{"+String(e));
  });

}

--> Orderlist.js

componentDidMount = () => {
this.focusListener = this.props.navigation.addListener( 'didFocus', payload => {
    this.setState({ curr_index: 0, orderType: "current", arrCurrData: [], arrPastData: [], page: 1 ,statusBarStyle: "dark-content"}, () => {
      this.apiCallMy_order_list(),
        this._retrieveData()
    })
    console.log("Type ===>",typeof ConnectyCube.users)
    // if(typeof ConnectyCube.users === "undefined") {
      EventRegister.emitEvent(EventsNames.USER_LOGIN, "user login"); // send event to app.js to start updating location
    // }
    this.setState({ statusBarStyle: "dark-content" })
  }
);

}

below is the code we do on press of the chat icon

onPress={() => {

          this.setState({isLoading : true})

          const searchParams = { email: item.user_email };
          if(typeof ConnectyCube.users === "undefined")
          {
            EventRegister.emitEvent(EventsNames.USER_LOGIN, "user login"); // send event to app.js to start updating location
          }
          else {

          ConnectyCube.users
            .get(searchParams)
            .then((result) => {

              const params = {
                type: 3,
                occupants_ids: [result.user.id],
              };

              ConnectyCube.chat.dialog
                .create(params)
                .then((dialog) => {
                  this.setState({isLoading : false} , () => {
                    this.props.navigation.navigate('OrderChat',{
                      name : item.name,
                      customer_notificationId : item.user_id,
                      chat_user_id : result.user.id,
                      dialog:dialog
                    })
                  })

                })
                .catch((error) => {});

            })
            .catch((error) => {

            });

          }

        }}

 Thanks
 Jigar 
DaveLomber commented 2 years ago

@GimmeForeDev1 looks good

can you do the following

1 - enable logs https://developers.connectycube.com/reactnative/?id=configuration

const CONFIG = {
  debug: { mode: 1 } // enable DEBUG mode (mode 0 is logs off, mode 1 -> console.log())
};
ConnectyCube.init(CREDENTIALS, CONFIG);

2 - try to login on iOS and reproduce the issue. Then collect all the logs from console and share there

we should find a root cause there