SlideShare a Scribd company logo
REACT
NATIVE
BRIDGE
FOR IOS
AND
ANDROID
www.bacancytechnology.com
React Native is combined with iOS and
Android. We can create a React Native
bridge between the Native languages like
Java, Kotlin, Objective-c, Swift, and
JavaScript code. Here bridge means the
communication between the native
platform and React Native.
Native Bridge Android
Native Bridge iOS
Table of Contents
1. Native Modules 
2. Native Bridge component
In this blog post, I will get you through both
Android as well as iOS.
Define Native Modules
Native modules are distributed as npm
packages, except that on top of the usual
Javascript, they will include some native
code per platform. To understand more
about npm packages, please go through this
useful Guide.
Native Module Steps:
Let’s understand the native modules with
examples.
Create the Exit App
We will create an ExitApp demo using react-
native CLI. In this example, button press to
exit the app using the native language.
Hopefully, your project runs successfully.
Native Bridge component
This tool comes handy for React Native
Developer to bridge the native component
1. Native Bridge Android
Create a new java class, ExitModule, and
ExitModulePackage.
ExitModule.java
⦿android/app/src/main/java/com/exitapp/
ExitModule.java
So it is a class that extends
ReactContextBaseJavaModule.
ReactContextBaseJavaModule implements a
method getName that returns a string.
getName() in string name, which we will
refer to the native module in our Javascript
code.
@ReactMethod java method should be
annotated to expose a method to JavaScript.
Multiple @ReactMethod methods can be
created in this class.
 React native bridge for iOS and android
ExitPackage.java
⦿android/app/src/main/java/com/exitapp/
ExitPackage.java
So it is a class that extends ReactPackage.
Registering new JS modules that can be
accessed from native modules or from other
parts.
The native code requires JS modules from
the package that doesn’t automatically be
included as a part of the JS bundle, so there
should be a corresponding piece of code on
the JS side that will require the
implementation of that JS module so that it
gets bundled.
 React native bridge for iOS and android
MainApplication.java
⦿android/app/src/main/java/com/exitapp/
MainApplication.java
ExitPackage add in MainApplication.java
Create new file ExitModule in Xcode
File/New/File/Cocoa Touch Class
2. Native Bridge iOS
ExitModule.h
⦿ios/ExitApp/ExitModule.h
RCTBridgeModule use in native land to talk
with React Native
ExitModule.m
⦿ios/ExitApp/ExitModule.m
React Native will not expose any methods
of ExitApp to JavaScript unless explicitly
told to. This is done using the
RCT_EXPORT_METHOD() macro:
Your class must also include the
RCT_EXPORT_MODULE() macro. RCT is
the short name for React and includes it in
your Objective-C code.
RCT_EXPORT_METHOD supports this
standard JSON object types:
NSString (string)
NSInteger, float, double, CGFloat,
NSNumber(number)
BOOL, NSNumber(boolean)
NSArray (array)
NSDictionary (object)
RCTResponseSenderBlock (function)
Finally, Android and iOS side native code
are completed. So ExitApp calls in react-
native in a javascript file.
NativeModule.js
App.js
OutPut:
Now run the app
To access the code of this blog post can be
accessed here .
In this blog, we have created UI
components using React Native JavaScript
code. If you are looking for the React Native
experts to create a bridge between
JavaScript code and native languages to
create native modules, then get in touch
with us today. Our React Native developers
are well-versed with building intuitive,
visually stunning, robust, scalable,
engaging, and user-friendly cross-platform
mobile applications.
We are a globally renowned React Native
Development company; we let you
outsource React Native developers from us
to gain a competitive advantage fulfilling
your varied business objectives.
Conclusion
Thank You

More Related Content

PDF
Dagger in multi module sdk
PDF
Kotlin workshop glimpse
PPTX
Android Development with Kotlin course
PPTX
Java Tutorial: Part 2. IntelliJ IDEA
PPTX
Android Dagger2
PDF
Creating Swing DSL with_Kotlin
ODP
The Lombok Project
PPTX
Android Dagger 2
Dagger in multi module sdk
Kotlin workshop glimpse
Android Development with Kotlin course
Java Tutorial: Part 2. IntelliJ IDEA
Android Dagger2
Creating Swing DSL with_Kotlin
The Lombok Project
Android Dagger 2

What's hot (20)

PPTX
Dependency injection using dagger2
PDF
Gwt and JSR 269's Pluggable Annotation Processing API
PDF
Jython Presentation
PDF
Cara Tepat Menjadi iOS Developer Expert - Gilang Ramadhan
PDF
Kotlin multiplataforma
PPTX
Web development tool
PDF
Study Jam: Android for Beginners, Summary
PDF
Angular 2 Seminar_(December 7/12/2015)
DOCX
Java articles
PPT
Android the Agile way
PPTX
Scala on-android
PDF
Presentation # 4
PDF
A journey with Target Platforms
PPTX
Gradle and Android Studio : Best of Friends
PPTX
Code Obfuscation for Android & WP7
PDF
Using Dagger in a Clean Architecture project
PPTX
How to build Sdk? Best practices
PPTX
Telerik Kendo UI vs. AngularJS
PDF
From zero to hero with React Native!
Dependency injection using dagger2
Gwt and JSR 269's Pluggable Annotation Processing API
Jython Presentation
Cara Tepat Menjadi iOS Developer Expert - Gilang Ramadhan
Kotlin multiplataforma
Web development tool
Study Jam: Android for Beginners, Summary
Angular 2 Seminar_(December 7/12/2015)
Java articles
Android the Agile way
Scala on-android
Presentation # 4
A journey with Target Platforms
Gradle and Android Studio : Best of Friends
Code Obfuscation for Android & WP7
Using Dagger in a Clean Architecture project
How to build Sdk? Best practices
Telerik Kendo UI vs. AngularJS
From zero to hero with React Native!
Ad

Similar to React native bridge for iOS and android (20)

PDF
React Native for multi-platform mobile applications
PDF
Workshop 26: React Native - The Native Side
PPTX
React native
PPTX
React Native’s New Architecture Decoded: How to Migrate & Benefits?
PDF
Mobile Day - React Native
PDF
Comparing Native and React Native App Development Company.pdf
PPTX
Native modules
PPTX
React Native for ReactJS Devs
PPTX
React native: building shared components for Android and iOS
PDF
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
PDF
A tour of React Native
PPT
Intro to react native
PPTX
React Native And Its Ecosystem Presentation
PDF
l1-reactnativeintroduction-160816150540.pdf
PPTX
React Native Building Mobile Apps with React.pptx
PDF
JSAnkara Swift v React Native
PPTX
React Native
PDF
Introduction to React Native - Lev Vidrak, Wix
PDF
What is React Native and When to Choose It For Your Project.pdf
PDF
The Gist of React Native
React Native for multi-platform mobile applications
Workshop 26: React Native - The Native Side
React native
React Native’s New Architecture Decoded: How to Migrate & Benefits?
Mobile Day - React Native
Comparing Native and React Native App Development Company.pdf
Native modules
React Native for ReactJS Devs
React native: building shared components for Android and iOS
React Native Introduction: Making Real iOS and Android Mobile App By JavaScript
A tour of React Native
Intro to react native
React Native And Its Ecosystem Presentation
l1-reactnativeintroduction-160816150540.pdf
React Native Building Mobile Apps with React.pptx
JSAnkara Swift v React Native
React Native
Introduction to React Native - Lev Vidrak, Wix
What is React Native and When to Choose It For Your Project.pdf
The Gist of React Native
Ad

More from Katy Slemon (20)

PDF
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
PDF
Data Science Use Cases in Retail & Healthcare Industries.pdf
PDF
How Much Does It Cost To Hire Golang Developer.pdf
PDF
What’s New in Flutter 3.pdf
PDF
Why Use Ruby On Rails.pdf
PDF
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
PDF
How to Implement Middleware Pipeline in VueJS.pdf
PDF
How to Build Laravel Package Using Composer.pdf
PDF
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
PDF
How to Develop Slack Bot Using Golang.pdf
PDF
IoT Based Battery Management System in Electric Vehicles.pdf
PDF
Understanding Flexbox Layout in React Native.pdf
PDF
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
PDF
New Features in iOS 15 and Swift 5.5.pdf
PDF
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
PDF
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
PDF
Flutter Performance Tuning Best Practices From the Pros.pdf
PDF
Angular Universal How to Build Angular SEO Friendly App.pdf
PDF
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
PDF
Ruby On Rails Performance Tuning Guide.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
Data Science Use Cases in Retail & Healthcare Industries.pdf
How Much Does It Cost To Hire Golang Developer.pdf
What’s New in Flutter 3.pdf
Why Use Ruby On Rails.pdf
How Much Does It Cost To Hire Full Stack Developer In 2022.pdf
How to Implement Middleware Pipeline in VueJS.pdf
How to Build Laravel Package Using Composer.pdf
Sure Shot Ways To Improve And Scale Your Node js Performance.pdf
How to Develop Slack Bot Using Golang.pdf
IoT Based Battery Management System in Electric Vehicles.pdf
Understanding Flexbox Layout in React Native.pdf
The Ultimate Guide to Laravel Performance Optimization in 2022.pdf
New Features in iOS 15 and Swift 5.5.pdf
How to Hire & Manage Dedicated Team For Your Next Product Development.pdf
Choose the Right Battery Management System for Lithium Ion Batteries.pdf
Flutter Performance Tuning Best Practices From the Pros.pdf
Angular Universal How to Build Angular SEO Friendly App.pdf
How to Set Up and Send Mails Using SendGrid in NodeJs App.pdf
Ruby On Rails Performance Tuning Guide.pdf

Recently uploaded (20)

PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Mushroom cultivation and it's methods.pdf
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Approach and Philosophy of On baking technology
PDF
project resource management chapter-09.pdf
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
A novel scalable deep ensemble learning framework for big data classification...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
August Patch Tuesday
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
A Presentation on Touch Screen Technology
PPTX
A Presentation on Artificial Intelligence
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Mushroom cultivation and it's methods.pdf
OMC Textile Division Presentation 2021.pptx
Approach and Philosophy of On baking technology
project resource management chapter-09.pdf
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
A novel scalable deep ensemble learning framework for big data classification...
SOPHOS-XG Firewall Administrator PPT.pptx
1. Introduction to Computer Programming.pptx
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Web App vs Mobile App What Should You Build First.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A comparative analysis of optical character recognition models for extracting...
Heart disease approach using modified random forest and particle swarm optimi...
Digital-Transformation-Roadmap-for-Companies.pptx
August Patch Tuesday
Univ-Connecticut-ChatGPT-Presentaion.pdf
A Presentation on Touch Screen Technology
A Presentation on Artificial Intelligence

React native bridge for iOS and android

  • 2. React Native is combined with iOS and Android. We can create a React Native bridge between the Native languages like Java, Kotlin, Objective-c, Swift, and JavaScript code. Here bridge means the communication between the native platform and React Native.
  • 3. Native Bridge Android Native Bridge iOS Table of Contents 1. Native Modules  2. Native Bridge component
  • 4. In this blog post, I will get you through both Android as well as iOS. Define Native Modules Native modules are distributed as npm packages, except that on top of the usual Javascript, they will include some native code per platform. To understand more about npm packages, please go through this useful Guide. Native Module Steps: Let’s understand the native modules with examples. Create the Exit App We will create an ExitApp demo using react- native CLI. In this example, button press to exit the app using the native language.
  • 5. Hopefully, your project runs successfully. Native Bridge component This tool comes handy for React Native Developer to bridge the native component 1. Native Bridge Android Create a new java class, ExitModule, and ExitModulePackage. ExitModule.java ⦿android/app/src/main/java/com/exitapp/ ExitModule.java So it is a class that extends ReactContextBaseJavaModule.
  • 6. ReactContextBaseJavaModule implements a method getName that returns a string. getName() in string name, which we will refer to the native module in our Javascript code. @ReactMethod java method should be annotated to expose a method to JavaScript. Multiple @ReactMethod methods can be created in this class.
  • 8. ExitPackage.java ⦿android/app/src/main/java/com/exitapp/ ExitPackage.java So it is a class that extends ReactPackage. Registering new JS modules that can be accessed from native modules or from other parts. The native code requires JS modules from the package that doesn’t automatically be included as a part of the JS bundle, so there should be a corresponding piece of code on the JS side that will require the implementation of that JS module so that it gets bundled.
  • 11. Create new file ExitModule in Xcode File/New/File/Cocoa Touch Class 2. Native Bridge iOS
  • 12. ExitModule.h ⦿ios/ExitApp/ExitModule.h RCTBridgeModule use in native land to talk with React Native ExitModule.m ⦿ios/ExitApp/ExitModule.m React Native will not expose any methods of ExitApp to JavaScript unless explicitly told to. This is done using the RCT_EXPORT_METHOD() macro:
  • 13. Your class must also include the RCT_EXPORT_MODULE() macro. RCT is the short name for React and includes it in your Objective-C code. RCT_EXPORT_METHOD supports this standard JSON object types:
  • 14. NSString (string) NSInteger, float, double, CGFloat, NSNumber(number) BOOL, NSNumber(boolean) NSArray (array) NSDictionary (object) RCTResponseSenderBlock (function) Finally, Android and iOS side native code are completed. So ExitApp calls in react- native in a javascript file. NativeModule.js
  • 16. OutPut: Now run the app To access the code of this blog post can be accessed here .
  • 17. In this blog, we have created UI components using React Native JavaScript code. If you are looking for the React Native experts to create a bridge between JavaScript code and native languages to create native modules, then get in touch with us today. Our React Native developers are well-versed with building intuitive, visually stunning, robust, scalable, engaging, and user-friendly cross-platform mobile applications. We are a globally renowned React Native Development company; we let you outsource React Native developers from us to gain a competitive advantage fulfilling your varied business objectives. Conclusion