React Native Toast iOS

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

Now create the Toast Function for iOS in ToastModule.
In the internal native toast Function I have used native iOS Taost Library

There are few steps to communicate from the Native method to React-Native in iOS.

  1.  Create a MobikulToast.h in you ios folder of the module

    A native module is an Objective-C class that implements the RCTBridgeModule protocol. If you are wondering, RCT is an abbreviation of ReaCT.
  2. In addition to implementing the 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.
    Now create the MobikulToast.m file that uses the RCTBridgeModuleand other methods for Toast.
  3. Now create method and expose on React Native code by using the RCT_EXPORT_METHOD

    In the above snippet “sampleMethod” is the name of the Native method that will call from ReactNative and it’s arguments. Now bellow snippet is my Toast module method.

    Supported Argument of RCT_EXPORT_METHOD

    • string (NSString)
    • number (NSIntegerfloatdoubleCGFloatNSNumber)
    • boolean (BOOLNSNumber)
    • array (NSArray) of any types from this list
    • object (NSDictionary) with string keys and values of any type from this list
    • function (RCTResponseSenderBlock)


  4.  Now Creating Constant for Module

Now Add this module in your Project by admin link our  PodFile.

Use MobikulToast in our project javascript class

Link for creating Android Toast- 

. . .

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