cometchat / chat-sdk-react-native

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

undefined is not a constructor (evaluating 'new _reactNativeChat.CometChat.CallSettingsBuilder()') #10

Closed victorstein closed 3 years ago

victorstein commented 4 years ago

Hello,

I get the following error when I try to call the CallSettingsBuilder method from comet chat.

undefined is not a constructor (evaluating 'new _reactNativeChat.CometChat.CallSettingsBuilder()')

I'm using expo and "@cometchat-pro/react-native-chat": "^2.1.0-beta1" for the project bootstrapping. Any help would be greatly appreciated. (paying customer here!) love the work you guys are doing with your service.

Every method I've tried Login, logout, listeners, etc works but this essential part.

code sample:

var callSettings = new CometChat.CallSettingsBuilder()
            .setSessionID(sessionId)
            .setCallEventListener(callListener)
            .setIsAudioOnlyCall(audioOnly)
            .build();
anantgarg commented 4 years ago

Hi @victorstein! We are releasing a new beta version which will support video calling. Please add yourself to this:

https://feedback.cometchat.com/cometchat-pro-feature-requests/p/customizable-voice-video-calling-for-react-native

We are targeting a release this week :)

mayur-bhandari commented 4 years ago

Hello @victorstein ,

We have released a beta version of our new calling component. Please update to v2.1.0-beta2.

Link to documentation: https://prodocs.cometchat.com/v2.1/docs/react-native-quick-start

danishkhalid1 commented 3 years ago

Hi @mayur-bhandari I am using react-native cli and facing same error when updating to v2.1.0-beta2. React native version: 0.59.9

Code sample: var callSettings = new CometChat.CallSettingsBuilder() .setSessionID(sessionId) .setCallEventListener(callListener) .build();

mayur-bhandari commented 3 years ago

Hello @danishkhalid1 ,

Please update to the latest version of the React Native SDK v2.1.4. Please let us know if you still face this issue.

danishkhalid1 commented 3 years ago

@mayur-bhandari facing same issue with this version too. Following to the documentation adding this allprojects { repositories { maven { url "https://dl.bintray.com/cometchat/pro" } } } causing app crash :( and without this, facing error TypeError: _reactNativeChat.CometChat.CallSettingsBuilder is not a constructor

danishkhalid1 commented 3 years ago

Hello @mayur-bhandari any update on this issue?

mayur-bhandari commented 3 years ago

Hello @danishkhalid1 ,

Can you please share the complete error log? Also, can you please share the exact code snippet? Because we are unable to reproduce this issue at our end.

danishkhalid1 commented 3 years ago

Hello @mayur-bhandari This is the error log TypeError: undefined is not a constructor (evaluating 'new _reactNativeChat.CometChat.CallSettingsBuilder()') MainCallScreen@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:546795:78 constructClassInstance@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:14176:32 updateClassComponent@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:17539:33 invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:8825:21 invokeGuardedCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:8921:42 beginWork$$1@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:23042:34 performUnitOfWork@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:22180:30 workLoopSync@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:22162:45 renderRoot@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21926:29 renderRoot@[native code] runRootCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21687:34 runRootCallback@[native code] http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12417:38 unstable_runWithPriority@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:43388:30 flushSyncCallbackQueueImpl@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12412:28 flushSyncCallbackQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12401:35 scheduleUpdateOnFiber@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21569:37 enqueueSetState@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:13970:23 setState@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:4702:37 dispatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:133093:27 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:133941:35 renderMainCallScreen@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:546654:39 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:546675:38 tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26836:16 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26937:27 _callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30979:17 _callImmediatesPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31015:19 callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31234:33 callImmediates@[native code] callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2572:35 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2349:34 guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2555:15 flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2348:21 flushedQueue@[native code] invokeCallbackAndReturnFlushedQueue@[native code]

MainCallScreen Code: / eslint-disable keyword-spacing / / eslint-disable react-native/no-inline-styles / / eslint-disable prettier/prettier / import React, {Component} from 'react'; import { View } from 'react-native'; import {CometChat} from '@cometchat-pro/react-native-chat'; export default class MainCallScreen extends Component {

constructor(props){
    super(props);
    let callListener = new CometChat.OngoingCallListener({
        onUserJoined: user => {
            console.log('OngoingCallListener: User joined call:', user.getUid());
        },
        onUserLeft: user => {
            console.log('OngoingCallListener: User left call:', user.getUid());
        },
        onCallEnded: call => {
            console.log('OngoingCallListener: Call ended listener', call.getSessionId());
            this.gotoChat();
        },
    });
    this.addCallListner();
    this.sessionId = props.navigation.getParam('sessionId','sessionid');
    this.defaultLayout = props.navigation.getParam('enableDefaultLayout', 1);
    this.entity = props.navigation.getParam('entity', {});
    this.entityType = props.navigation.getParam('entityType', 'user');
    this.acceptedFrom = props.navigation.getParam('acceptedFrom', 'Home');
    this.callSettings = new CometChat.CallSettingsBuilder().setSessionID(this.sessionId).enableDefaultLayout(true).setCallEventListener(callListener).build();
}

static navigationOptions = () => {
    return {
       header: () => null,
    };
}

addCallListner(){
    var listnerID = 'MAIN_CALLING_SCREEN_CALL_LISTENER';
    CometChat.addCallListener(
        listnerID,
        new CometChat.CallListener({
            onIncomingCallReceived(call) {
                var sessionID = call.getSessionId();
                var status = CometChat.CALL_STATUS.BUSY;
                CometChat.rejectCall(sessionID, status).then(
                    rejectedCall => {
                        console.log('Incoming Call rejected', rejectedCall);
                    },
                    error => {
                        console.log('Call rejection failed with error:', error);
                    }
                );
            },
        })
    );
}

componentWillUnmount(){
    CometChat.removeCallListener('MAIN_CALLING_SCREEN_CALL_LISTENER');
}

gotoChat(){
    this.props.navigation.goBack();
}

render(){
    return(
        <View style={{flex: 1, background: '#000'}}>
            <CometChat.CallingComponent callSettings= {this.callSettings} onFailure = {(e)=>{console.log('error', e);}} />
        </View>
    );
}

}

mayur-bhandari commented 3 years ago

Hello @danishkhalid1 ,

Can you please let us know what issue are you facing when you add the following:

allprojects {
    repositories {
        maven {
             url "https://dl.bintray.com/cometchat/pro"
        }
    }
}

The above code is necessary to use calling in Android. Also, can you please confirm if you are using SDK v2.1.4? I would suggest you clear your npm cache and delete node_modules and reinstall all the packages using npm install.

danishkhalid1 commented 3 years ago

Hi @mayur-bhandari I can update my react native version to 0.61 and add this dependency in build.gradle file I am using Cometchat Version 2.1.0 and call version 1.0.0

danishkhalid1 commented 3 years ago

Hello @mayur-bhandari After clearing cache and node modules and reinstalling the modules, this error occur

TypeError: undefined is not an object (evaluating 'g.getCallEventListener') e@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:227645:16 constructClassInstance@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:14176:32 updateClassComponent@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:17539:33 invokeGuardedCallbackImpl@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:8825:21 invokeGuardedCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:8921:42 beginWork$$1@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:23042:34 performUnitOfWork@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:22180:30 workLoopSync@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:22162:45 renderRoot@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21926:29 renderRoot@[native code] runRootCallback@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21687:34 runRootCallback@[native code] http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12417:38 unstable_runWithPriority@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:43388:30 flushSyncCallbackQueueImpl@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12412:28 flushSyncCallbackQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:12401:35 scheduleUpdateOnFiber@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:21569:37 enqueueSetState@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:13970:23 setState@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:4702:37 dispatch@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:133093:27 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:133941:35 renderMainCallScreen

tryCallOne@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26836:16 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:26937:27 _callTimer@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:30979:17 _callImmediatesPass@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31015:19 callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:31234:33 callImmediates@[native code] callImmediates@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2572:35 http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2349:34 guard@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2555:15 flushedQueue@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2348:21 flushedQueue@[native code] invokeCallbackAndReturnFlushedQueue@[native code]

danishkhalid1 commented 3 years ago

Fix this issue by changing <CometChat.CallingComponent callSettings= {this.callSettings} onFailure = {(e)=>{console.log('error', e);}} /> to <CometChat.CallingComponent callsettings= {this.callSettings} onFailure = {(e)=>{console.log('error', e);}} />

mayur-bhandari commented 3 years ago

Hello @danishkhalid1 ,

Can you please confirm that clearing the npm cache, reinstalling the packages, and following the documentation correctly solved your issue?

danishkhalid1 commented 3 years ago

yes @mayur-bhandari this changes solved my issue

aagam29 commented 3 years ago

Facing a similar issue, As per the documentation for a direct call here,

let callSettings = new CallSettings.CallSettingsBuilder().enableDefaultLayout(deafaultLayout).setSessionId(sessionID).setIsAudioOnly(audioOnly).setCallEventListener(callListener).build();

But it's not mentioned from where to import the CallSettings class, getting import errors when trying to import from the obvious @cometchat-pro/react-native-chat or @cometchat-pro/react-native-calls Import error: `TypeError: undefined is not an object (evaluating 'new _reactNativeChat.CallSettings.CallSettingsBuilder'

Then, I tried to do a let callSettings = new CometChat.CallSettingsBuilder().enableDefaultLayout(deafaultLayout).setSessionId(sessionID).setCallEventListener(callListener).setIsAudioOnly(audioOnly).build();

Then I got, TypeError: new _reactNativeChat.CometChat.CallSettingsBuilder().enableDefaultLayout(deafaultLayout).setSessionId is not a function. (In 'new _reactNativeChat.CometChat.CallSettingsBuilder().enableDefaultLayout(deafaultLayout).setSessionId(sessionID)', 'new _reactNativeChat.CometChat.CallSettingsBuilder().enableDefaultLayout(deafaultLayout).setSessionId' is undefined)

TypeError: undefined is not a function (near '...ener).setIsAudioOnly(audioOnly).build();...')

Commented both those function calls and simply did let callSettings = new CometChat.CallSettingsBuilder() .enableDefaultLayout(deafaultLayout) .setCallEventListener(callListener) .build();

Then I got, 
nothing just a blank white space from `CometChat.CallingComponent` 

My comet chat versions are @cometchat-pro/react-native-calls": "^1.0.3" @cometchat-pro/react-native-chat": "^2.1.6"

I have cleared npm cache and reinstalled the packages.

Not sure what is going wrong here, can you please look into this?