cometchat / chat-sdk-react-native

Voice & Video Calling and Text Chat SDK for React Native
Other
18 stars 17 forks source link

[Android] Cannot read property 'localStorage' of undefined #22

Closed tr3v3r closed 3 years ago

tr3v3r commented 3 years ago

I make short POC using this SDK and sometimes I am getting the error Cannot read property 'localStorage' of undefined. I suppose localStorage is not part of the React Native environment.

The issue is reproduced from time to time.

Steps to reproduce: 1) create App at CometChap pro dashboard 2) init and log in using superhero1 or superhero2 or superhero3 user ( test users provided by service ) image image


useEffect(() => {

      setLoading(true)
      const appSetting = new CometChat.AppSettingsBuilder()
        .subscribePresenceForAllUsers()
        .setRegion(REGION)
        .build()
      CometChat.init(APP_ID, appSetting).then(
        () => {
          console.log('Initialization completed successfully')
          CometChat.login('superhero2', AUTH_KEY).then(
            User => {
              console.log('Login Successful:', { User })

              // User loged in successfully.
            },
            error => {
              console.log('Login failed with exception:', { error })
              // User login failed, check error and take appropriate action.
            },
          )
        },
        error => {
          console.log('Initialization failed with error:', error)
          // Check the reason for error and take appropriate action.
        },
      )

      return () => CometChat.logout()

  }, [])

Platform: Android (28 SDK) "@cometchat-pro/react-native-calls": "^1.0.3", "@cometchat-pro/react-native-chat": "2.1.4", "react-native": "0.62.2",

mayur-bhandari commented 3 years ago

Hello @tr3v3r ,

We were aware of this issue and have already released a fix for the same. Can you please update to the latest React Native SDK v2.1.5.