<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Atchaya Jayabal</title>
    <description>The latest articles on DEV Community by Atchaya Jayabal (@atchayajayabal).</description>
    <link>https://dev.to/atchayajayabal</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1178760%2Ff6af7f1b-0b1c-4fac-9a4a-20d370d84ada.jpg</url>
      <title>DEV Community: Atchaya Jayabal</title>
      <link>https://dev.to/atchayajayabal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atchayajayabal"/>
    <language>en</language>
    <item>
      <title>Tutorial To Add Real-time Call Features To Your Client App In 30 mins</title>
      <dc:creator>Atchaya Jayabal</dc:creator>
      <pubDate>Fri, 06 Oct 2023 14:45:08 +0000</pubDate>
      <link>https://dev.to/atchayajayabal/tutorial-to-add-real-time-call-features-to-your-client-app-in-30-mins-421f</link>
      <guid>https://dev.to/atchayajayabal/tutorial-to-add-real-time-call-features-to-your-client-app-in-30-mins-421f</guid>
      <description>&lt;p&gt;Creating a chat app using Plugin can be a great way to add real-time chat features to your Flutter app. &lt;/p&gt;

&lt;p&gt;In this tutorial, I will guide you through the process step by step, making it clean and simple to understand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before we begin, ensure you have the following prerequisites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter SDK &lt;/li&gt;
&lt;li&gt;Flutter Project&lt;/li&gt;
&lt;li&gt;Basic knowledge of Flutter and Dart programming&lt;/li&gt;
&lt;li&gt;MirrorFly Flutter Plugin&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2: Set Up Your Flutter Project
&lt;/h2&gt;

&lt;p&gt;Start by creating a new Flutter project or using an existing one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Add the Plugin Dependencies
&lt;/h2&gt;

&lt;p&gt;Open your &lt;strong&gt;pubspec.yaml&lt;/strong&gt; file and add the following dependencies:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dependencies:&lt;br&gt;
  mirrorfly_plugin: ^0.0.7&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Run &lt;strong&gt;flutter pub&lt;/strong&gt; get in your project directory to fetch and install the dependencies.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Initialize MirrorFly Plugin
&lt;/h2&gt;

&lt;p&gt;In your &lt;strong&gt;main.dart&lt;/strong&gt; file, initialize the MirrorFly Plugin in the &lt;strong&gt;main&lt;/strong&gt; function before calling &lt;strong&gt;runApp&lt;/strong&gt;. Replace '&lt;strong&gt;Your_Mirrorfly_Licence_Key&lt;/strong&gt;' with your actual MirrorFly license key and '&lt;strong&gt;Your_iOS_app_Group_id&lt;/strong&gt;' with your iOS app group ID if you're targeting iOS.&lt;br&gt;
&lt;code&gt;void main() {&lt;br&gt;
  WidgetsFlutterBinding.ensureInitialized();&lt;br&gt;
  Mirrorfly.init(&lt;br&gt;
      baseUrl: 'https://api-preprod-sandbox.mirrorfly.com/api/v1/',&lt;br&gt;
      licenseKey: 'Your_Mirrorfly_Licence_Key',&lt;br&gt;
      iOSContainerID: 'Your_iOS_app_Group_id');&lt;br&gt;
  runApp(const MyApp());&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: User Registration
&lt;/h2&gt;

&lt;p&gt;To register a user in the chat, use the &lt;strong&gt;Mirrorfly.registerUser&lt;/strong&gt; method. Replace '&lt;strong&gt;userIdentifier&lt;/strong&gt;' with a unique user ID, and optionally pass an FCM token if needed.&lt;br&gt;
&lt;code&gt;Mirrorfly.registerUser('userIdentifier').then((value) {&lt;br&gt;
  var userData = registerModelFromJson(value);&lt;br&gt;
}).catchError((error) {&lt;br&gt;
  debugPrint(error.message);&lt;br&gt;
});&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Send a One-to-One Message
&lt;/h2&gt;

&lt;p&gt;To send a one-to-one text message to another user, you need to get their JID (Jabber ID) first using **Mirrorfly.getJid. **Then, use **Mirrorfly.sendTextMessage **to send the message.&lt;br&gt;
&lt;code&gt;var userJid = await Mirrorfly.getJid('username');&lt;br&gt;
Mirrorfly.sendTextMessage('message', userJid).then((value) {&lt;br&gt;
  var chatMessage = sendMessageModelFromJson(value);&lt;br&gt;
});&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Receive One-to-One Messages
&lt;/h2&gt;

&lt;p&gt;To receive one-to-one messages, you can listen for incoming messages using &lt;strong&gt;Mirrorfly.onMessageReceived.&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;Mirrorfly.onMessageReceived.listen((result) {&lt;br&gt;
  var chatMessage = sendMessageModelFromJson(result);&lt;br&gt;
  // Handle the received message here&lt;br&gt;
});&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
That's it! You've successfully set up a basic chat app using the &lt;a href="https://www.mirrorfly.com/flutter-chat-api.php"&gt;MirrorFly Chat Plugin for Flutter&lt;/a&gt;. You can expand upon this foundation to create a full-featured chat application with features like group chats, multimedia messages, and more.&lt;/p&gt;

&lt;p&gt;Remember to handle user authentication, message storage, and other essential aspects of a chat application as your project evolves. Additionally, check the &lt;a href="https://pub.dev/packages/mirrorfly_plugin"&gt;official plugin&lt;/a&gt; documentation for more advanced features and customization options.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
