React Native native module method is string

So I have very weird issue and i spent already nice amount of time trying to figure out what is going on. When I export method to JS it says it is string not a function :(.

Here is my bridge file:

#import <Foundation/Foundation.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>

@interface RCT_EXTERN_MODULE(FRAuthSampleBridge, NSObject)

//Used in the ReactNative Sample
RCT_EXTERN_METHOD(start: (NSDictionary *)options resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(login: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(register: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(next: (NSString *)response type:(NSString *)type resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(logout)
RCT_EXTERN_METHOD(getUserInfo: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(getAccessToken: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(uaePassLogin: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(getUaePassCode: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(forgotPassword: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(changePassword: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
RCT_EXTERN_METHOD(refreshToken: (RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)

@end

and here is part of my custom module

@objc func start(
      _ options: NSDictionary,
      resolve: @escaping RCTPromiseResolveBlock,
      rejecter reject: @escaping RCTPromiseRejectBlock) {

      FRLog.setLogLevel([.all])

      // Safely cast the NSDictionary to [String: Any]
      guard let optionsDict = options as? [String: Any] else {
          reject("Error", "Failed to cast NSDictionary to [String: Any]", nil)
          return
      }

      let frOptions = FROptions(config: optionsDict)

      do {
          try FRAuth.start(options: frOptions)
          DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
              if (FRAuth.shared != nil) {
                  resolve("SDK initialized")
              } else {
                  reject("Error", "SDK not initialized; please check the log for details", nil)
              }
          }
      }
      catch {
          FRLog.e(error.localizedDescription)
          reject("Error", "SDK failed during initialization", error)
      }
  }

And when i do this in JS

console.log(FRAuthSampleBridge);
console.log(typeof FRAuthSampleBridge.start);

I get:

 LOG  {"changePassword": [Function promiseMethodWrapper], "forgotPassword": [Function promiseMethodWrapper], "getAccessToken": [Function promiseMethodWrapper], "getConstants": [Function anonymous], "getUaePassCode": [Function promiseMethodWrapper], "getUserInfo": [Function promiseMethodWrapper], "login": [Function promiseMethodWrapper], "logout": [Function nonPromiseMethodWrapper], "next": [Function promiseMethodWrapper], "refreshToken": [Function promiseMethodWrapper], "register": [Function promiseMethodWrapper], "start": "start", "uaePassLogin": [Function promiseMethodWrapper]}
 LOG  string

So my start method is string and not a function. Any idea how to solve this issue?! I tried to clean project, remove derived data, rebuild again but always same.

Leave a Comment