cometchat / chat-sdk-react-native

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

TypeError: Cannot read property 'data' of null while Initialize call #36

Closed gajjartejas closed 4 months ago

gajjartejas commented 5 months ago
 LOG  loggedInUser:1:  {"authToken": "dev_11740_1718172135053a153cdd3ec8d357cb5cfb665c5d", "avatar": "https://lawzebra-dev-original.s3.us-east-2.amazonaws.com/users/17162074893581.jpg", "blockedByMe": false, "deactivatedAt": 0, "hasBlockedMe": false, "lastActiveAt": 1718173813, "metadata": {"fcmTokens": ["dlVU0l3rBZM:APA91bG4gNA_ulOl5bMXj0D-E8V9eZxWsYgZOsbpuLic6I1tMOXvFjYD6vnR8PyO4-8bouWvGn3bAEG3BT_WFJ7hKVPaL3MqW36MS5UJpYiKUzcZ6VnP8MDJNjGEdvXF-mb8lFYS2vOV", "e2y-Cta27U4ljMRO-4T5x6:APA91bEWJvRbdFXZuC_Es6ONY8xrqNN8NHV9ZNTBhKafvsGdzjw1XdJpBNqYBhCo_G2ZSAsy8M4VbWOJlUSqqYAuVFm7i3hGyG71w2HSD9zhiqIn8BKwkMluymOS4ePGPACRatwgj1AT", "dnZ1fV76qEIXiuNya7-jzH:APA91bGinzLZ7fQmvqbg6V6HU4ZYgknHxOGODYnxm2IeTyLGjGZW8HpteX7fL3as_Wayt_ppA2RRWQG2h5Y498a8GivpQp9_iq4kxzxhougfUHJINdLKrfLy8QF8fzdwnADSmZndEBFL", "fGdk0SuTomM:APA91bElxnv2aukw4ga1Zj4OSP8laB0Wrl_vwe3T87HGb_nOMJg65HAcGCPxiXf7Fo7ssfOQJzhZ-bC7uaPibSM6hnT3g3QDQkuBNYr1thRRMV8HefU9Pc47B3XaVZ4u1tsGFfEG6mux", "ckR1Z7Y-aUwThL2CfYAzub:APA91bEF0VSHI8P2scDSX9LqyZ1FFHTluoYAvYi1qKOwSqgupxOV3YZrGBjnakv6qhQXeebHUG-QvP1b1z1_S6jlZ1v6OaCNwC0X6DQ9kTKgmYo2e0ZW4o8vRC3BOiHCnOs_ODBTPvbG", "cvSVWqluSEqGyqk9_sFJPx:APA91bHExmEQFf86wALiQXeop3mLi-KsDQWe37dv7mfn-VRraiQ5DMfzGrl_V5OyUFYJNNxMXJA5JjcXlnoTiSMhwuBEJovRa78cdP1KPx4dg6PMsUvIB9_7dxNIDQpCU2xAOXZKC1Nv", "dMPt-3q0EU3rlzlRM5rGgK:APA91bEYFkQmbH-qQ3L-1jvQRUJnaxEQkT_eHMqYfsBR5aIDwqvpjbw7x4SQ-MdsGkFR8eGPfpPaIS-wKDsVNmjPM83JIB7uIfBq82mSF3QMX8ndSllYKlzIoq6loh6C8c7XDUOBMJxo", "dq6jcAAQRVO1uKoTUCcRGb:APA91bFHYsU8WQ_UUBX2bgYj7iNMvRlC86B14hYCyP1SXQ4yqjkWVsaXR9lggsV5dx1mJBI3CwW1d9rLedd1y43rSpn9-2CG0dxpk_wl6hjO1y8GebEk7yRFWh0VFL9--jnoMlDmrxPd", "dSZ5EBKKvUMxmA0zTZamTM:APA91bF9QFvadj7YYYfNdCmYdUB6wlZdoPBF_wM0Wq4bCK1uiFCblnRZXpYVQ2SEbVH1stzRllmWyAA0fSier4ASeekCi9WQ2VXWdx6pd_WBZ5lXqfJuURaLJ4Ajnw5cTXJDaSwahAIO", "eVSxaNM3c0tzkrB6JG7nSv:APA91bHpdhBbekA6NIO8XjmRXP52XawdGL-0fO-EL7sNz3c82CUc5JOnpGb9aMEzvL65gpporzzTzzUObTOBmYKgpfqgj_1BCrouZ4bN0mvdCcXdk2s2XKgLc0UxBx6-kUnGxjrhaT8o"], "notificationEnabled": true, "type": 2}, "name": "chintans1", "role": "default", "status": "online", "uid": "dev_11740"}
 LOG  callToken:1:  found
 LOG  callSettings:1:  found
 LOG  [SyntaxError: JSON Parse error: Unexpected character: <]
 LOG  Call Error:1:  {"code": "API_ERROR", "details": [TypeError: Cannot read property 'data' of null], "message": "Unknown API error"}
 ERROR  [TypeError: Cannot read property 'data' of null]

Here is a code:

let sessionID = `${this.props.item.guid}`;
    console.log('sessionID:1: ', sessionID);
    let audioOnly = this.props.callType === CometChat.CALL_TYPE.AUDIO;
    let callListener = new CometChatCalls.OngoingCallListener({
      onCallEnded: call => {
        console.log('startCall:1: ', JSON.stringify(call));
        this.props.close();
        this.sendCallEndNotification();
      },
      onError: error => {
        this.props.actionGenerated(actions.CALL_ERROR, error);
        console.log('Call Error:1: ', error);
      },
    });
    let loggedInUser = await CometChat.getLoggedinUser();
    console.log('loggedInUser:1: ', loggedInUser);
    try {
      let callToken = await CometChatCalls.generateToken(sessionID, loggedInUser.getAuthToken());
      console.log('callToken:1: ', callToken ? 'found' : 'not found');
      let callSettings = new CometChatCalls.CallSettingsBuilder()
        .enableDefaultLayout(false)
        .setIsAudioOnlyCall(audioOnly)
        .setCallEventListener(callListener)
        .build();
      console.log('callSettings:1: ', callSettings ? 'found' : 'not found');
      this.setState({
        callToken: callToken.token,
        callSettings: callSettings,
      });

Render:

  render() {
    return (
      <Modal animated animationType="fade">
        <View style={{ height: '100%', width: '100%', position: 'relative' }}>
          <KeepAwake />
          {this.state.callSettings && this.state.callToken ? (
            <CometChatCalls.Component callSettings={this.state.callSettings} callToken={this.state.callToken} />
          ) : null}
        </View>
      </Modal>
    );
  }

Deps used

    "@cometchat/chat-sdk-react-native": "^4.0.7",
    "@expo/react-native-action-sheet": "^4.0.1",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-clipboard/clipboard": "^1.13.2",
    "@react-native-community/datetimepicker": "^7.6.3",
    "@react-native-community/geolocation": "^3.2.1",
    "@react-native-community/hooks": "^3.0.0",
    "@react-native-community/netinfo": "^11.3.1",
    "@react-native-community/push-notification-ios": "^1.11.0",
    "@react-native-firebase/analytics": "^20.1.0",
    "@react-native-firebase/app": "^19.2.2",
    "@react-native-firebase/crashlytics": "^19.2.2",
    "@react-native-firebase/dynamic-links": "^19.2.2",
    "@react-native-firebase/messaging": "^19.2.2",
    "@react-native-masked-view/masked-view": "^0.3.1",
    "@react-native-picker/picker": "^2.7.2",
    "@react-navigation/bottom-tabs": "^6.5.20",
    "@react-navigation/drawer": "^6.6.15",
    "@react-navigation/material-top-tabs": "^6.6.13",
    "@react-navigation/native": "^6.1.17",
    "@react-navigation/stack": "^6.3.29",
    "@twotalltotems/react-native-otp-input": "^1.3.11",
    "aws-sdk": "^2.1589.0",
    "axios": "^1.6.8",
    "axios-curlirize": "^2.0.0",
    "crypto-js": "^4.2.0",
    "emittery": "^1.0.3",
    "emoji-mart-native": "^0.6.5-beta",
    "i18next": "^23.10.1",
    "intl": "^1.2.5",
    "ismounted": "^0.1.8",
    "moment": "^2.30.1",
    "moment-range": "^4.0.2",
    "rbush": "^3.0.1",
    "react": "18.2.0",
    "react-i18next": "^14.1.0",
    "react-native": "0.72.12",
    "react-native-adjust": "^4.38.0",
    "react-native-autolink": "^4.2.0",
    "react-native-aws3": "^0.0.9",
    "react-native-background-timer": "^2.4.1",
    "react-native-base64": "^0.2.1",
    "react-native-bootsplash": "^5.4.1",
    "react-native-calendars": "^1.1304.1",
    "react-native-callstats": "3.73.7",
    "react-native-code-push": "^8.2.1",
    "react-native-communications": "^2.2.1",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-create-thumbnail": "^2.0.0",
    "react-native-device-info": "^10.13.1",
    "react-native-document-picker": "^9.1.1",
    "react-native-easy-icon": "^1.0.10",
    "react-native-elements": "^3.4.3",
    "react-native-fast-image": "^8.6.3",
    "react-native-file-viewer": "^2.1.5",
    "react-native-fs": "^2.20.0",
    "react-native-gesture-handler": "^2.16.0",
    "react-native-image-crop-picker": "^0.40.3",
    "react-native-image-picker": "^7.1.2",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-in-app-review": "^4.3.3",
    "react-native-keep-awake": "^4.0.0",
    "react-native-keyboard-accessory": "^0.1.16",
    "react-native-keyboard-manager": "^6.5.11-2",
    "react-native-localize": "^3.0.6",
    "react-native-maps": "1.15.3",
    "react-native-masked-text": "^1.13.0",
    "react-native-modal": "^13.0.1",
    "react-native-modal-datetime-picker": "^17.1.0",
    "react-native-modalize": "^2.1.1",
    "react-native-pager-view": "^6.3.0",
    "react-native-permissions": "^4.1.5",
    "react-native-popup-menu": "^0.16.1",
    "react-native-progress": "^5.0.1",
    "react-native-purchases": "^7.27.1",
    "react-native-push-notification": "^8.1.1",
    "react-native-reanimated": "3.12.0",
    "react-native-render-html": "^6.3.4",
    "react-native-safe-area-context": "^4.9.0",
    "react-native-safearea-height": "^1.0.6",
    "react-native-screens": "^3.30.1",
    "react-native-scroll-bottom-sheet": "^0.7.0",
    "react-native-set-soft-input-mode": "^1.1.0",
    "react-native-share": "^10.1.0",
    "react-native-snap-carousel": "^3.9.1",
    "react-native-sound": "^0.11.2",
    "react-native-star-rating": "^1.1.0",
    "react-native-store-version": "^1.4.1",
    "react-native-svg": "^15.1.0",
    "react-native-swipe-list": "^0.0.2",
    "react-native-swipe-list-view": "^3.2.9",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^3.5.2",
    "react-native-text-ticker": "^1.14.0",
    "react-native-toast-message": "^2.2.0",
    "react-native-vector-icons": "^10.0.3",
    "react-native-video": "^5.2.1",
    "react-native-video-controls": "^2.8.1",
    "react-native-view-shot": "^3.8.0",
    "react-native-webrtc": "1.106.1",
    "react-native-webview": "^13.8.4",
    "react-redux": "^7.2.4",
    "redux": "^4.1.1",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "redux-saga": "^1.3.0",
    "redux-thunk": "^2.3.0",
    "rn-fetch-blob": "^0.12.0",
    "simple-react-validator": "^1.6.2",
    "tiny-emitter": "^2.1.0"
cometchat-helpcenter-bot commented 5 months ago

Rosanne Fernando (CometChat Team) replied:

Hello Tejas,

Thanks for reaching out with your concern. I am Rosanne from the Support team.

I've forwarded your issue to the implementation team. You will be hearing from them shortly.

Regards.

Rosanne Fernando CometChat

gajjartejas commented 5 months ago

Hello,

we have paid account in the comet chat for walid@lawzebras.com if this issue not solved, we are going to drop SDK soon, video/audio calls working for some user and not working for some users like above issue. Screenshot 2024-06-12 at 12 17 46 PM

cometchat-helpcenter-bot commented 5 months ago

Afroz Khan (CometChat Team) replied:

Hi there,

We have reviewed your implementation, and everything appears to be working fine on our end. To help us investigate further, could you please share few test users UID who are facing this issue along with the AppId, App region and authKey.

You can share the Auth Key with us securely using https://onetimesecret.com. This can be easily deleted once our testing is complete. Also, please don’t forget to share the passphrase so we can access the key.

Regards,

Afroz Khan CometChat

gajjartejas commented 4 months ago

Hello,

We have resolved the issue by deleting the user, recreating the user with the same ID, and adding the user back to the group from cometchat. This approach has fixed the problem for now. We will monitor the situation and inform you if the issue reoccurs.

Thank you.

cometchat-helpcenter-bot commented 4 months ago

Afroz Khan (CometChat Team) replied:

Hi,

Thank you for the update. I'm glad to hear that the issue has been resolved by deleting and recreating the user. Please continue to monitor the situation and let us know if the issue reoccurs.

Best regards,

Afroz Khan CometChat