Create the iOS bridge

Create the native files for your module by opening your workspace file on Xcode, select your project, and right-click to add a new file. Select Cocoa Touch Class, give the name, and create it.

Step 1 - BridgeClassDemo.h

Create the bridge by copying the code below into your BridgeClassDemo.h file

BridgeClassDemo.h
//
//  BridgeClassDemo.h
//  RaxelPulseReactNativeDemo
//
//  Created by Sergey Emelyanov on 19/04/2020.
//  Copyright © 2020 Data motion Pte.Ltd. All rights reserved.
//  https://telematicssdk.com

#import "React/RCTBridgeModule.h"

// Instead of BridgeClassDemo put the name of your module
@interface BridgeClassDemo : NSObject <RCTBridgeModule>
@end

Step 2 - DemoClass.m

Add the code below into your DemoClass.m file:

Step 3 - AppDelegate

Handle library methods for AppDelegate as it is in the example below:

And that’s it for the native side.

Step 4 - React Native side

We can now call it anywhere on the React Native side:

Last updated

Was this helpful?