As an iOS developer, you may find yourself asking one day: how do I integrate native iOS frameworks into my React Native application? This blog will shows you how to add an iOS native framework in react native project.
Custom SDK which provides you basic details of the card and in return the package displays the card details.
Open the iOS folder in the React Native project with Xcode.
Use this Framework as a SDK
Add your XCFramework file here by dragging and dropping it in Frameworks, Libraries, and Embedded Content.
Switch to AppDelegate.m in the iOS folder and import the framework and import the react native project name as header:
Import the React Native project Name in the header.
Example:“testframework” is the name of the project
Replace with your project name and import in the header.
Add the native modules and invoke framework methods in AppDelegate as below the implementation of AppDelegate .
[self invokeFramework:props[@”dict”][@”deviceId”] :props[@”dict”][@”env”] :props[@”dict”][@”number”] :props[@”dict”][@”sdkAuth”] :props[@”dict”][@”priOrgId”] :props[@”dict”][@”templetType”] :props[@”dict”][@”language”] ];
//Invoking the CustomeriOSFramework
– (void)invokeFramework:(NSString*)deviceId :(NSString*)env :(NSString*)number : (NSString*)sdkAuth : (NSString*)priOrgId : (NSString*)templetType : (NSString*)language
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
NSBundle *amazingBundle = [NSBundle bundleForClass:[LoadingVC class]];
LoadingVC *yourVC = [[LoadingVC alloc] initWithNibName:@”LoadingVC” bundle:amazingBundle];
yourVC.env = env;
yourVC.number = number;
yourVC.deviceId = deviceId;
yourVC.sdkAuth = sdkAuth;
yourVC.priOrgId = priOrgId;
yourVC.templetType = templetType;
yourVC.language = language;
[[UIApplication sharedApplication].delegate.window.rootViewController presentViewController :yourVC animated:YES completion:nil];
Write a calling method in React Native Project as on the specified as per developer choice Check out the below code snippet for the same.
Import the NativeModules:
Calling and passing the props to the Customerframework through Native Modules:
‘env’: ‘PROD’, //provide environment here
‘number’: ’91*******’,//provide mobile number here
‘deviceId’: ‘************’,//provide device id here
‘sdkAuth’: ‘*********************************’, //provide Authentication Token here
‘priOrgId’: ‘*****’, //provide primary organization id here
‘templetType’: ‘********’, //provide your template name here
‘language’: ‘en’ //provide language type here
👉 A native application screen will appear in a react native project.
Additional reading: How to Add an iOS Native Framework in the Flutter Project?