Curious_guy
Curious_guy

Reputation: 161

Why native function written in objective C is is not returning anything?

I am trying to get output from native function to use in frontend, here is the function,

RCT_EXPORT_METHOD(getActiveAudioDevice:
                 resolver:(RCTPromiseResolveBlock)resolve
                 rejecter:(RCTPromiseRejectBlock)reject)
{
  MediaDevice * _Nullable  devices = [meetingSession.audioVideo getActiveAudioDevice];
  NSLog(@"Hello Devices: %@", devices);
  
  if (!devices) {
    reject(@"event_failure", @"failed to list audio devices", nil);
  } else {
    resolve(devices);
  }

}

I am triggering it in JS like this ,

const selectedAudioDevice = useCallback(async() => { 

       const activeDevice= await NativeFunction.selectedDevice("")
       setActiveDevice(activeDevice) }

When I trigger this from frontend I can see in logs that Native function is returning a device but in JS all I get is undefined, any idea what I am doing wrong here ?

Upvotes: 1

Views: 264

Answers (0)

Related Questions