react-native-deepar icon indicating copy to clipboard operation
react-native-deepar copied to clipboard

No command found with name ""

Open tuugi0113 opened this issue 1 year ago • 4 comments

what is causing this and how to fix it

tuugi0113 avatar Aug 20 '23 06:08 tuugi0113

@ridvanaltun i am facing the same issue , can you please show me the right way to fix that This error is only occurred in IOS Device

KaushalRamani99 avatar Aug 21 '23 07:08 KaushalRamani99

@ridvanaltun I confirm facing this issue on iOS device. For Android everything works fine.

Alex86Chuk avatar Oct 27 '23 11:10 Alex86Chuk

@ridvanaltun I'm seeing the same issue here.

I found that UIManager.getViewManagerConfig("RNTDeepARView").Commands returns {"switchEffect":0,"switchEffectWithPath":1,"fireTrigger":2,"setFlashOn":3,"pause":4,"resume":5,"takeScreenshot":6,"startRecording":7,"resumeRecording":8,"pauseRecording":9,"finishRecording":10,"setAudioMute":11,"setLiveMode":12,"setFaceDetectionSensitivity":13,"showStats":14,"setTouchMode":15,"changeParameterFloat":16,"changeParameterVec4":17,"changeParameterVec3":18,"changeParameterBool":19,"changeParameterTexture":20,"changeParameterString":21,"getConstants":22}

so when javascript triggers nativeExesute in node_modules/react-native-deepar/lib/module/DeepARView.js

const nativeExecute = (name, params) => {
    return UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), UIManager.getViewManagerConfig(NATIVE_VIEW_KEY).Commands[name] || '', params);
  };

it would make sense that UIManager.getViewManagerConfig(NATIVE_VIEW_KEY).Commands["switchEffect"] returns 0 thus resulting in an empty string command

what gets registered in UIManager.getViewManagerConfig("RNTDeepARView").Commands seems to be related to RNTDeepARViewManager.m my workaround for now is to modify RNTDeepARViewManager.m to add another not used function above the line RCT_EXPORT_METHOD(switchEffect like so

RCT_EXPORT_METHOD(notUsed
                  : (nonnull NSNumber *)reactTag andMaskPath
                  : (NSString *)effect andSlot
                  : (NSString *)slot) {
  [self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager,
                                      NSDictionary<NSNumber *, RNTDeepAR *>
                                          *viewRegistry) {
    RNTDeepAR *view = viewRegistry[reactTag];
    if (![view isKindOfClass:[RNTDeepAR class]]) {
      RCTLogError(
          @"Invalid view returned from registry, expecting RNTDeepAR, got: %@",
          view);
    } else {
      [view switchEffect:effect andSlot:slot];
    }
  }];
}

Now the commands look like this

{"notUsed":0,"switchEffect":1,"switchEffectWithPath":2,"fireTrigger":3,"setFlashOn":4,"pause":5,"resume":6,"takeScreenshot":7,"startRecording":8,"resumeRecording":9,"pauseRecording":10,"finishRecording":11,"setAudioMute":12,"setLiveMode":13,"setFaceDetectionSensitivity":14,"showStats":15,"setTouchMode":16,"changeParameterFloat":17,"changeParameterVec4":18,"changeParameterVec3":19,"changeParameterBool":20,"changeParameterTexture":21,"changeParameterString":22,"getConstants":23}

I'm very new to react native and not sure about the consequences with this modification. But switchEffect works again. If anyone can explain the issue better here and provide a real solution that will be much appreciated.

Yi-Eyetell avatar Jan 15 '24 23:01 Yi-Eyetell

Thanks @Yi-Eyetell for the workaround. It worked for me as well on iOS. Using RN 0.74.1

My question to @ridvanaltun is do we actually need the or condition on

UIManager.getViewManagerConfig(NATIVE_VIEW_KEY).Commands[name] || ''

andresteves avatar May 27 '24 10:05 andresteves