Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i built a voice calling feature in my react native app? #182

Open
xts-bit opened this issue May 27, 2023 · 0 comments
Open

how can i built a voice calling feature in my react native app? #182

xts-bit opened this issue May 27, 2023 · 0 comments

Comments

@xts-bit
Copy link

xts-bit commented May 27, 2023

i am developing a college chat app project can anyone tell me how can i built a voice calling feature in my react native app?

i explored a service called voximplant.com that do that How can i do in my case i have two users chatting the first user is me and i am getting my id from asyncstorage and the otheruser id coming coming like this otheruser._id Can anyone tell me how will things will work in my case?

import Voximplant from 'react-native-voximplant';

Voximplant.SDK.init({
  bundleId: 'com.example.app',
  authToken: 'auth_token',
});

// Connect to the Voximplant cloud
Voximplant.SDK.connect();

// Create two users
const user1 = 'user1';
const user2 = 'user2';

// Log in as user1
Voximplant.SDK.login(user1, user1);

// Log in as user2
Voximplant.SDK.login(user2, user2);

// Call user2 from user1
Voximplant.SDK.callUser(user2);

// Handle incoming calls from user1
Voximplant.SDK.on(Voximplant.Event.CallIncoming, (event) => {
  const call = event.call;
  if (call.headers['X-User-Id'] === user1) {
    call.answer();
  } else {
    call.reject();
  }
});

// Handle call events
Voximplant.SDK.on(Voximplant.Event.CallConnected, (event) => {
  console.log('Call connected');
});
Voximplant.SDK.on(Voximplant.Event.CallDisconnected, (event) => {
  console.log('Call disconnected');
});
Voximplant.SDK.on(Voximplant.Event.CallFailed, (event) => {
  console.log('Call failed');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant