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

Attempt to read from field 'com.twilivoicreatenative.jsEventEmitter com.twiliovoicereactnative.Voice application OnProxy.jsEventEmitter on a null object reference' #446

Open
3 tasks
aniket620-rcrm opened this issue Nov 5, 2024 · 1 comment
Assignees
Labels
needs more info Needs more info from the issue author.

Comments

@aniket620-rcrm
Copy link

aniket620-rcrm commented Nov 5, 2024

Issue

Pre-submission Checklist

  • I have verified that the issue occurs with the latest release and is not marked as a known issue in the CHANGELOG.md.
  • I reviewed the Common Issues and open GitHub issues and verified that this report represents a potentially new issue.
  • I am not sharing any Personally Identifiable Information (PII)
    or sensitive account information (API keys, credentials, etc.) when reporting this issue.

Description

When we run npm run android. we got this issue when app starts opening Please check the image for reference.
image

Reproduction Steps

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Behavior

We can't proceed further without resolving this issue.

Actual Behavior

What actually happens.

Reproduction Frequency

It happens everytime.

Screenshots

If applicable, add screenshots to help explain your problem.

Software and Device Information

Please complete the following information.

  • Device: [e.g. iPhone 15]
  • OS: [e.g. iOS 18, Android API Level 34]
  • React version: [e.g. 18.2.0]
  • React Native version: [e.g. 0.73.6]
  • Node version: [e.g. 18.0.0]
  • npm or yarn version: [e.g. 8.6.0, 1.22.22]

Additional Context

Add any other context about the problem here.

code

import React, { useEffect, useState } from 'react';
import { View, Text, Button, Alert } from 'react-native';
import { Voice } from '@twilio/voice-react-native-sdk';
import { getTokenForIncomingCall } from '../../redux/selectors';

const IncomingCallHandler = () => {
  const [voice, setVoice] = useState(null);
  const [isRegistered, setIsRegistered] = useState(false);

  useEffect(() => {
    const initializeVoice = async () => {
      try {
        const token = await getTokenForIncomingCall(); // Fetch access token from your backend
        const voiceInstance = new Voice();
        setVoice(voiceInstance);

        // Register for incoming calls
        await voiceInstance.register(token);
        setIsRegistered(true);
        console.log('Device registere for incoming calls');

        // Handle incoming call invites
        voiceInstance.on('callInvite', (callInvite) => {
          Alert.alert('Incoming Call', 'You have an incoming call.', [
            {
              text: 'Accept',
              onPress: () => {
                callInvite.accept();
                console.log('Call accepted');
              },
            },
            {
              text: 'Reject',
              onPress: () => callInvite.reject(),
              style: 'cancel',
            },
          ]);
        });

      } catch (error) {
        console.error('Error initializing voice SDK:', error);
      }
    };

    initializeVoice();

    // Cleanup function to unregister on component unmount
    return () => {
      if (voice && isRegistered) {
        voice.unregister().then(() => console.log('Device unregstered')).catch((err) => console.error('Error during unregistration:', err));
      }
    };
  }, []);


  return (
    <View>
      <Text>{isRegistered ? 'Listening for incoming calls...' : 'Registering...'}</Text>
      <Button title="Make Outgoing Call" onPress={makeOutgoingCall} />
    </View>
  );
};

export default IncomingCallHandler;
@mhuynh5757
Copy link
Collaborator

Have you followed the Getting Started documentation for your respective platform? Please check the README of this repo for more documentation on how to integrate the SDK into your app.

@mhuynh5757 mhuynh5757 self-assigned this Nov 5, 2024
@mhuynh5757 mhuynh5757 added the needs more info Needs more info from the issue author. label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Needs more info from the issue author.
Projects
None yet
Development

No branches or pull requests

2 participants