Browse Author: Shravankumar Gundawar

I am working as an iOS application developer at NanoStuffs Technologies Pvt. Ltd. since 9 months. I have total 2+ years of experience in this technology. Till date worked on more than 7 iOS applications, Includes the categories of shopping,Entertainment,Business etc. Other than this, i love singing songs & proud to say that won many prizes for solo and duet singing competitions during school and college days.

Integration of Chat Library and Firebase in iOS Project

Group chat is a very easy and good approach for having the communication in any mobile application. Today we are going to dive into an implementation of “Group Chat Using Firebase”.

While implementing this functionality in mobile application the very important and challenging task is creating an UserInterface for chatting screen, so for designing this screen we will go with the “JSQMessageViewController” it is an open source library for chatting.

Let’s see the procedure for implementing  “JSQMessageViewController”  to design chat screen. For more info you can take help from this link 

First of all create a new swift project, Now open terminal window and enter the command : cd (your project path).

After this command we will enter into our project folder, for using JSQMessageViewController we need to install pods into our project.


Procedure to install PODS : 

  1. Run “pod init” command on terminal. (It will create a Podfile into our project folder)
  2. open that created Podfile and enter pods for JSQMessageViewController (ie.pod JSQMessagesViewController)
  3. Now Save the file and close it.
  4. Again go to terminal window and run “pod install” command. (It will install all the dependencies of JSQMessagesViewController to our project and also create a new project file with .xcworkspace extension).
  5. Now open projectName.xcworkspace file in xcode.

We are done with all prerequisites for chat screen design,  JSQMessagesViewController have used collectionView for showing message bubble, so to display the message bubble into our project we need to implement all DataSource & Delegates for CollectionView created by JSQMessagesViewController.


It is very important to display all chat messages taken place in chat group so that need to be pushed/dump somewhere and retrieve  from somewhere. So for achieving this we are going to use “FIREBASE“.

Firebase is a mobile and web application development platform. It also provides a realtime database, so to achieve the above mentioned scenario we will use the firebase as a database.To create an environment for using firebase into our app we need to follow some steps to setup some prerequisites, please take a reference from this link for more info.

Steps to integrate firebase into our project :

  1. Go to this link  
  2. Login with your gmail credentials.
  3. click on “Go To Console” on top right corner.
  4. Now need to create a new app space, on firebase for our app. To create app space on firebase click on “Add Project”
  5. Fill up all the required information on the given popup and click on “CreateProject”.
  6. Now go to “Authentication” tab on left hand side, click on sign-in methods and enable “Email/Password” by clicking that field.
  7. Go to “Project Setting” -> “General” -> “Add firebase to your app” and fill all the information and complete the procedure. At the end it will create a .plist file that you need to add into our project.
  8. After importing .plist file to our project it’s time to install PODS for firebase.
  • Open existing Podfile from project.
  • Add pod ‘Firebase/Core’ to Podfile, save and close the file.
  • Follow all the steps whichever we done for installing JSQMessagesViewController pods.


Now you are perfectly ready with environment to implement chatting app in iOS using firebase as a realtime database.




Custom Protocol and Delegate

Custom protocols and delegate is the very efficient way to passing values to other controller from one controller. If we required pass the value for only one controller in entire project the we should not go for declaring “Global Variable” to pass the values.

Example:  Display PopOver for option selection on button click event which placed on TableViewCell. On option selection make some changes on TableView.

Let’s assume ViewController of tableview is (VC-1) andViewController of  PopOver is (VC-2).

Here the actual process of CODING get started,

create one table view with custom cell on (VC-1) then design for PopOver/ popUp on (VC-2).

Now we have to pass value from  (VC-2) to  (VC-1) so create custom protocol and delegate on  (VC-2) as below

protocol popOverListViewControllerDelegate {

    func getSelectedValueFromPopOverList(str:String)


place this above code outside the block of class.

Now declare a variable of delegate inside (VC-2) as below

var delegate : popOverListViewControllerDelegate?

go to option selection event on (VC-2) ie. didSelect method of  popOver table and copy the below code.

this line of code will pass the value to (VC-1)

delegate?.getSelectedValueFromPopOverList(str: arrOptions[indexPath.row])

here is the end of Custom Protocol and Delegate declaration. Let us move to (VC-1) to write the further code.

First of all import the protocol popOverListViewControllerDelegate in (VC-1).

It’s  time to set the delegate, to set the delegate create an instance of (VC-2) and set the delegate as below

let popController = UIStoryboard(name: “Main”, bundle: nil).instantiateViewController(withIdentifier: “popListViewController”) as! popListViewController

  popController.delegate = self

Finally we will get the value which was passed by (VC-2) to (VC-1) using below code.

below code is the actual definition of the delegate which we created/declared in  (VC-2)

func getSelectedValueFromPopOverList(str:String)  {

    print(“I got value which is passed from(VC-2) : \(str)”)



Here is the Demo Project for this tutorial #HaveFun 🙂




Subclassing in Swift

Subclassing is a very simple and useful concept of inheritance, when we create a subclass of any existing class then that custom class inherits all the methods and properties of existing or predefined class and moreover we can add our own user defined properties and methods to it.


Here is the syntax with example for subclassing ,

class myCustomButton : UIButton


var section = Int()


Problem Statement :-

Consider the example of TableView and it consist Two Section and multiple rows in each section, every table cell has one UIButton and we want to get existing “Row” and “Section” for clicked UIButton.



UIButton has property call “tag” , by setting  the “indexPath.row” we can get row  indexfor selected button but for getting section for selected button we can use above example of subclass.

Now change cellForRow datasource code as below.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

         let cell = demoTableView.dequeueReusableCell(withIdentifier: “cell”, for: indexPath) as!demoTableView

         cell.btn.tag = indexPath.row

         cell.btn.section = indexPath.section

         return playersCell



Finally select button from table view and set “myCustomButton” as superclass to that button.

Animated Launch Screen

Basically when we want to set an image for LaunchScreen then we use LaunchScreen.storyboard for setting an image, but as this file does not have any class file (eg .swift or .h & .m) so we can not write code for animating that image at runtime. To achieve this we need to use main.storyboard

Steps to implement animated Launch Screen : –

1) Click on project name on ProjectNavigatorPanel -> go to Target.

2) Scroll down  to “Main Interface” -> click down arrow -> change  LaunchScreen.storyboard to Main.

3) Go to Main.storyboard -> Select your view controller for which you want to set animated Launch Screen.

4) Select your view controller -> click on Editor on top menu bar -> Embed In -> select Navigation Controller

5) Set Navigation Controller as Initial ViewController of your project.

Now create a class for writing code of animation and connect it to view controller on Main.storyboard , Once the animation is done you can push a view controller to next view controller programmatically.


NOTE : You can write any type of animation code in that class file (eg .swift) as per your requirements. I have used .gif image for LaunchScreen using code from “Swift+Gif.swift” file.Have a fun with animation Code Here