React Native Native bridge

Updated 6 March 2021

Save

React Native Native bridge :

React Native bridge is a way to communicate with the native code. With the help of the Native bridge concept, your .js code can call the native code.

We are going to create a native bridge for IOS :

First of all, open your ios project workspace. Then add a new file to your root project and choose the Objective-C type file. Just named that file that you want to name. In my case, I am used the “IOSNativeBridge”.

IOSNAtiveBridge.h :

After that, there is another file you have to create with the same name but it is .m file.

IOSNAtiveBridge.m :

Here iosNativeMethod is our native method name. and value1 and value2 are two parameters that we call from the js code.

Bridge.js (JavaScript code):

Now, from your JavaScript file you can call the method like this (after making sure to rebuild):

 

Reference:  https://reactnative.dev/docs/native-modules-ios/

 

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home