twilio / twilio-voice-react-native

Other
72 stars 27 forks source link

Unable to use package: JSEventEmitter error #348

Open weixinnnn opened 6 months ago

weixinnnn commented 6 months ago

Version

@twilio/voice-react-native-sdk: "^1.0.0-beta.4" Android API 34 Java JDK 17

Issue

As soon as I install the package, Attempt to read from field 'com.twiliovoicereactnative.JSEventEmitter com.twiliovoicereactnative.VoiceApplicationProxy.jsEventEmitter' on a null object reference error will be shown

Reproduction Steps

  1. yarn add @twilio/voice-react-native-sdk
  2. yarn android
  3. Application restarted and error shown

Screenshots

image

mhuynh5757 commented 6 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly:

https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

omerts commented 6 months ago

@mhuynh5757 I am having a hard time understanding what needs to be added from the PR. Is there just a straight forward guide? For example we are handling permission using another lib, and I don't want to mix permission handling. How should 'VoiceActivityProxy' be setup? I would appreciate just a minimal guide of how to migrate to beta4 from existing solution, without breaking changes... BTW, putting permission handling inside the java code, breaks our i18n, which is not java based. React native is meant for Javascript.

Also a guide for latest react-native which uses kotlin will be appreciated.

mhuynh5757 commented 6 months ago

Hi all, thanks for the feedback. The team is internally discussing priorities for improving our documentation and onboarding. We understand there might be some documentation pain points and we aim to reduce friction for everyone. I cannot share any timelines at this point, but please stay tuned!

@omerts thanks for the specific feedback, I'll forward this to the team.

iamsiddharthkamble commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly:

https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

this resolve issue , but when I call register method with token I get response null

iamsiddharthkamble commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly:

https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757

How to do this with Kotlin for the latest React Native 0.73.2

tmodoux commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757

How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

ObaidHere commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757 How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

Hi, @tmodoux am using React Native 0.73.4 after implementing the changes you gave, still there something is missing getting error. file:///...etc/MainApplication.kt:37:34 Unresolved reference: MainReactNativeHost. file:///..etc/MainReactNativeHost.kt.kt:9:54 Unresolved reference: BuildConfig.

tmodoux commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757 How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

Hi, @tmodoux am using React Native 0.73.4 after implementing the changes you gave, still there something is missing getting error. file:///...etc/MainApplication.kt:37:34 Unresolved reference: MainReactNativeHost. file:///..etc/MainReactNativeHost.kt.kt:9:54 Unresolved reference: BuildConfig.

Hi, I think you should adapt package com.androidapp in the three files so that it matches your actual package name, also in MainActivity.kt you should adapt override fun getMainComponentName(): String = "REPLACE_WITH_YOUR_APP_NAME".

It seems that you also have a typo in your file name MainReactNativeHost.kt.kt.

iamsiddharthkamble commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757 How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

I use these for my app, and call register method like

const registerCall=async()=>{
  // Allow incoming calls
  try{
    const registerCallResult = await voice.register(token);
    console.log(registerCallResult,"registerCallResult")
  }catch(e){
    console.log(e,'error at registerCallResult')
  }

}

this, so now I get console log is like LOG null registerCallResult

Is that OK for now to get Incoming calls or do We need to get the console log like 'authorised' or 'registered'

iamsiddharthkamble commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757 How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

I use these for my app, and call register method like

const registerCall=async()=>{
  // Allow incoming calls
  try{
    const registerCallResult = await voice.register(token);
    console.log(registerCallResult,"registerCallResult")
  }catch(e){
    console.log(e,'error at registerCallResult')
  }

}

this, so now I get console log is like LOG null registerCallResult

Is that OK for now to get Incoming calls or do We need to get the console log like 'authorised' or 'registered'

also I check logs in android studio where log is like

2024-04-24 10:41:50.314 17029-17029 WindowOnBackDispatcher  com.pickmeup                         W  sendCancelIfRunning: isInProgress=falsecallback=android.view.ViewRootImpl$$ExternalSyntheticLambda22@ccdbd2
2024-04-24 10:41:50.374 17029-31393 TrafficStats            com.pickmeup                         D  tagSocket(3) with statsTag=0x3e8, statsUid=-1
2024-04-24 10:41:50.426 17029-17029 HandWritingStubImpl     com.pickmeup                         I  refreshLastKeyboardType: 1
2024-04-24 10:41:50.426 17029-17029 HandWritingStubImpl     com.pickmeup                         I  getCurrentKeyboardType: 1
2024-04-24 10:41:51.729 17029-31393 Twilio:Acc...okenParser com.pickmeup                         I  [Platform] JWT token HEADER: {"alg":"HS256","typ":"JWT","cty":"twilio-fpa;v=1"}
2024-04-24 10:41:51.740 17029-17029 TwilioVoic...tiveModule com.pickmeup                         I  Successfully registered FCM
2024-04-24 10:41:51.740 17029-17029 TwilioVoic...tiveModule com.pickmeup                         D  getJSEventEmitter().sendEvent(ScopeVoice, event)scopeVoice
2024-04-24 10:41:51.740 17029-17029 VoiceApplicationProxy   com.pickmeup                         D  VoiceApplicationProxy.instance.jsEventEmitter com.twiliovoicereactnative.JSEventEmitter@6e21f44
2024-04-24 10:41:51.740 17029-17029 JSEventEmitter          com.pickmeup                         D  sendEvent scopeVoice params {"type":"voiceEventRegistered"}
2024-04-24 10:41:51.740 17029-17029 JSEventEmitter          com.pickmeup                         D  Inside If if ((null != context.get() && context.get().hasActiveReactInstance()))com.facebook.react.bridge.ReactApplicationContext@ec0add6
2024-04-24 10:41:51.741 17029-31028 Twilio:EventPublisher   com.pickmeup                         D  [Platform] Start publishing events to : https://eventgw.twilio.com/v4/EndpointEvents
                                                                                                    {"name":"registration","group":"registration","timestamp":"2024-04-24T05:11:51.734Z","level":"INFO","private":false,"payload_type":"application\/json","publisher":"twilio-voice-android-react-native","publisher_metadata":{"client_address":"FE80::7451:6AFF:FEA0:9C6D","os_name":"android","os_version":"14","device_model":"23049PCD8I","device_vendor":"Xiaomi","device_type":"23049PCD8I","cpu_architecture":"arm64-v8a"},"payload":{"timestamp_ms":1713935511730,"sdk_version":"1.0.0-beta.4","platform":"android","request_sid":"RQ6cc8af304198adc70cd95555bedac1b1"}}
2024-04-24 10:41:51.750 17029-31114 ReactNativeJS           com.pickmeup                         I  null, 'registerCallResult'
2024-04-24 10:41:51.761 17029-31420 TrafficStats            com.pickmeup                         D  tagSocket(157) with statsTag=0x90000, statsUid=-1

this. please confirm Is this ok? and we can do next feature implementation like "Incoming Call"

ObaidHere commented 5 months ago

on await voice.register(token), getting FirebaseApp.initailizeApp error, dose this require firebase?

yagitoshiro commented 5 months ago

@ObaidHere

Generate google-services.json and save it in android/app/, and then add dependency to android/build.gradle may fix the problem.

...
    dependencies {
        ...
        classpath("com.google.gms:google-services:4.4.1")
    }
}
apply plugin: 'com.google.gms.google-services'
dialmyline commented 5 months ago

Hello @weixinnnn please refer to this documentation to configure the Android platform correctly: https://github.com/twilio/twilio-voice-react-native/blob/main/docs/migration-guide-beta.4.md

@mhuynh5757 How to do this with Kotlin for the latest React Native 0.73.2

Hi, glad if it can help anybody else, I managed to make it works with the following kotlin files in my android/app source code (React Native app) :

are you using expo, because the bare react-native app has java code.

am using expo, and would like your help

SidMasih commented 4 months ago

@solidneeds you need to prebuild expo and then modify the KT code you can't use expo go and this lib!

dialmyline commented 4 months ago

@solidneeds you need to prebuild expo and then modify the KT code you can't use expo go and this lib!

did you get it to work

dialmyline commented 4 months ago

@SidMasih where do i modify KT code, which folder

do you have snippets

shridhar-toptal commented 4 months ago

@tmodoux you saved my day man. Thank You.

dwbelliston commented 4 weeks ago

@dialmyline there is a thread here https://github.com/twilio/twilio-voice-react-native/issues/132 that is working towards getting this to run with managed expo.

The thing with managed, the .kt files are not available since expo generates those on build. The expo module api seems like a promising solution for managed expo.