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

React-native bridge for iOS in swift

$
0
0

I’m trying to build a bridge between a native payment sdk (in swift) and react-native app, but I’m facing an issue and I hope you’d help me.all of these files inside csnative folder of the app.

here is the Payment.swift

import UIKit@objc(Payment)class Payment: NSObject {@objc public func getCardInfo(_ cardName: String,cardNumber:NSInteger,securityCode:NSInteger,expirationMonth:NSInteger,expirationYear:NSInteger) -> String {print(“inside payment”)//some codereturn result}

and this is csnative-Bridging-Header.h file

#import <React/RCTBridgeModule.h>

and finally the Payment.m

#import <React/RCTBridgeModule.h>@interface RCT_EXTERN_MODULE(Payment, NSObject)RCT_EXTERN_METHOD(getCardInfo:(NSString *)cardName(NSInteger *)cardNumber(NSInteger *)securityCode(NSInteger *)expirationMonth(NSInteger *)expirationYear)@end

and finally in the .js file I import NativeModules from react-native then call it as bellow:

let testPayment=NativeModules.Payment.getCardInfo(“Test”,12345,123,05,21)

I saw a lot of articles and tried a lot of ways but still, I get the same error

ExceptionsManager.js:82 Exception ‘getCardInfo: is not a recognized Objective-C method.’ was thrown while invoking getCardInfo on target Payment with params (“Test”,12345,123,05,21)

react-native version: 0.59.10

Swift version: 5

Xcode version: 11.5

any help would be really appreciated

Thank you!


Viewing all articles
Browse latest Browse all 16750

Trending Articles



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