Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

React native not a recognised objective C method

$
0
0

I am trying to bridge a call-back from native module to react native. I have tried this as well Got "is not a recognized Objective-C method" when bridging Swift to React-Native

I have added underscore to my first parameter as well

Following is my swift code

import Foundationimport LocalAuthentication@objc(FingerPrintModule)class FingerPrintModule: NSObject {  var resultCallback: RCTResponseSenderBlock!  @objc func authenticateLocallyForIos(_ callback: @escaping RCTResponseSenderBlock) -> Void {    resultCallback = callback    useLocalAuthentication()  }  private func useLocalAuthentication(){    //Business logic  }}

I have created objective c file for my swift file as well

#import <Foundation/Foundation.h>#import <React/RCTBridgeModule.h>#import <UIKit/UIKit.h>@interface RCT_EXTERN_MODULE(FingerPrintModule, NSObject)RCT_EXTERN_METHOD(authenticateLocallyForIos: callback:(RCTResponseSenderBlock)callback)@end

When I call from react native I get error saying not recognised objective c method

my React Native code

import { NativeModules,  Platform,} from "react-native";const { FingerPrintModule } = NativeModules;

Called on button press

FingerPrintModule.authenticateLocallyForIos((err, result) => {        if (!err) {          Alert.alert(result.toString());        } else {          Alert.alert(err);        }      });

Viewing all articles
Browse latest Browse all 16552

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>