Updated 22 September 2023
In this blog, I am implementing Toast Module functions for iOS and how to use those functions in our React Native Application?
In my previous blog, we know that how to create a React native Library and how to import in our Existing Application? Now, I am lighting my previous blog for What is the Module?
The module is a very important thing in our development, By using module we split our problems into many parts or we can generalize our problems into a specific form. In this blog, I will focus on how to create a module in the react-native project and how to implement it on our existing project manually.
How to create a Module?
-> Please click on the link to open my previous blog to create a module
https://mobikul.com/creating-module-for-react-native/
Now create the Toast Function for iOS in ToastModule.
In the internal native toast Function I have used native iOS Taost Library https://github.com/scalessec/Toast.
There are few steps to communicate from the Native method to React-Native in iOS.
RCTBridgeModule
protocol. If you are wondering, RCT is an abbreviation of ReaCT.RCTBridgeModule
protocol, your class must also include the RCT_EXPORT_MODULE()
macro. This takes an optional argument that specifies the name that the module will be accessible as in your JavaScript code (more on this later). If you do not specify a name, the JavaScript module name will match the Objective-C class name. If the Objective-C class name begins with RCT, the JavaScript module name will exclude the RCT prefix.RCTBridgeModule
and other methods for Toast.NSString
)NSInteger
, float
, double
, CGFloat
, NSNumber
)BOOL
, NSNumber
)NSArray
) of any types from this listNSDictionary
) with string keys and values of any type from this listRCTResponseSenderBlock
)
Now Add this module in your Project by admin link our PodFile.
Use MobikulToast in our project javascript class
Link for creating Android Toast- https://mobikul.com/toastmodule-for-android/
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.