Connecting to MQTT in Swift & IOS

MQTT is a Message Queuing Telemetry Transport protocol, it is also called MQ Telemetry Transport. It is widely used in IOT (Internet of Things) to have a good connectivity between machine and machines (machine-to-machine M2M). It is designed to be  extremely lightweight to publish/subscribe messaging transport. It is useful for connections with remote locations where a small code footprint is required and/or network bandwidth is at a premium. It is widely used in different areas like sensor communications, satellite broker link, dialup connection, healthcare providers and home automations. It is extremely ideal for Mobile Application because of its light weight, low power usage and minimised data packets.. For more information about MQTT visit Here.

I recently had a chance to implement it to one of the smart home application i developed, Therefore i thought of sharing my experience relate  to development. I have implemented this Protocol to my IOS application using Swift programming language.

Instruction to implement MQTT

One of the MQTT library available for IOS is called Moscapsule Visit Here

Lets get started……………..

Add these two lines to your podfile

run the command pod install. Then close and open your .workspace file

Now you have the Moscapules added to you project, open your AppDelegate.swift file and ad the following codes. You can see the comments inside the code itself

Thats it, Its very simple to connect, Since you have implemented this code in you AppDelegate, You can start the connection from anywhere inside the application by calling

You can check connection and subscribe to topics

The best way to send to your view controllers is buy Broadcasting the received message in onMessageCallback . Here is how i have done it.

You can add a broadcast receiver to you ViewController so that you can receive this broadcast

Thats it, Its very simple. Hope this helps for someone.

If you have any Question or suggestions please leave it below in the comments section. Happy Coding 🙂 . Enjoy MQTT


Smart Home (IOT) Project

Smart Home project done for leading internet service provider in Singapore and Malaysia. Smart Home is a one among many solutions they provide to their customer. Smart home is a complete security solution which supports almost all Z-Wave sensors, IOT devices and many more smart home appliances. This product is also expected to go live with the integration of leading market voice assistant such as Alexa and Google echo voice assistance.

Responsibilities: IOS Developer

  • Requirement analysis and design architecture for mobile programming.
  • Select suitable technology and library such as MQTT for the feasible solution.
  • Design, develop the mobile application IOS platform
  • Collaborate with designing team to ensure best user experience

 Key Areas: #MQTT, #Signal-R, #Swift,  #XML, #Rest, #Json, #pushNotifications, #cocoapods


ZupportDesk Live chat System

Live chat system is a realtime chat application, Using this system users can add a simple chat widget to their websites and whenever a new visitor comes to that website, you will be notified and you can have a realtime chat with visitors. Its not that simple as i say, Its a huge system that will help to solve customers inquiries and also help to identify what their customers specifically looking on their website and giving them the realtime support from the time they visit the website and till they exit the site. As a mobile application developer my task is to develop a realtime chat communication application to integrate with this system for both IOS and Android Platforms.

Technologies used to build this system are Xcode, Objective-C, cocoapods, Signal-R, Google Maps, Android Studio, Java, Rest Apis, Gson

These are some of the screenshots of the application i developed


ZupportDesk Ticket System

ZupportDesk Ticket System is a customer support ticket solution. Using this system customers can send their queries or problems via email and those email will automatically converted to ticket. Ticket System helps the support team to escalate customers problem in a  professional manner, it also help the companies to analyse the pattern of recurring problems and find a permanent solution. My task a mobile application developer i have to develop a ticket application for both IOS and Android platform with will collaborate with our common api module to sync the entire system. Technologies used in this application are Android Studio, Java, Xcode, Objective -C, Rest Api, cocoapods and Gson. These are some of the screenshots of the application i have developed.



My Places – Android Application

Its a simple android application i developed on my own interest to explore new technologies. This application will helps to log all the new places you visit and also to share it with your friends and families. The application also has features like

– Live GPS update
– Live Altitude Update
– Live GPS Accuracy meter
– Get directions to the places
– Get full details about a place.
– Live Map to display all your places
– Keep your data safe in cloud, enjoy sync.

Technologies used in this project are SQLite, Google Places Library, Google Maps, GPS, Android Studio and Java

Its available on play store :

These are some of the screenshots of the application i developed.

Be Like bro

Its a simple memes application with over 50,000 Memes. I developed this app because of the interest i had on memes. you might have a question, how i got these 50,000 memes? Well, I wrote a script to automatically download memes from Facebook and save it on my server over a long period of time. This application was a great success and have over 20,000 downloads as today and more than 200 people installing the app every day.

This app is great for time killing. have fun download it now (

Here are some screenshots of the application.

Certis Agent Tracking System

This is my first ever commercial application i developed. Certis is a company that provides security guards to other company, Certis has agents who go and check these security guards. My task was to develop an application that will track the location of agent every 2 minutes and update the system, also using this system admins can send new task to their agents in real time and agents also can update the status of the task and pickup a their new task using the mobile application itself.

Technologies used in this application are Java, Android Studio, Google services, Google maps, Geo fencing, Rest Api

These are some of the screens of the application i developed.

Jaffna Temples Android app

Jaffna Temples is a Mobile Application, that will help the users to locate the nearby by temples from their location and also get the easiest direction and route path to visit those temples. This project started as my final year project at college. I as a sole developer done research, design and development for this project, which ultimately gained me a grade A and contributed to get a 2nd class Upper division at the end of my Bachelor’s Degree program.  I also published the project on play store (

Here are some screen shots of the application i developed.


Protect Yourself From WannaCry Ransomware Attacks

Last week the earth experienced a largest global Ransomware attack in internet history and we were not able to defend or handle it, rather we are just good at calculating the damage caused but Wannacry program. The damages are in both human lives at hospitals and in dollars. This malware has encrypted more than 200,000 computers in more than 150 countries.

What is a Ransomware?

It is a simple computer malicious program written by programmers and often transmitted by emails as a attachment. Once the user try to download the attachment from the mail by double clicking the program will execute and start doing its work. First it will encrypt all the files and folders in your computer and then it will look for SMB ( Server Message Block ) connection in network, then the  Ransomware is spread to other computers in your network through SMB network connection.

In this particular wannacry program when the user try to open his files  and folders, it opens a program saying “oops your files have been encrypted” , It also asks you to pay a $300 to $600 in bitcoin to restore access to your files and folders. If you failed to make the payment within 7days your files will be permanently deleted from your system.

what are the major casualties?

An estimate of 40 hospital in UK has been fully effected by this attack and some of them had lead to fully close the out patient department for days.

Unapproved online sources says, there are company’s paid up to $60,000  to regain accesses to their files, but since the Bitcoin currency is virtual account and the bitcoin account owner is anonymous, its hard to find who had really paid and how much he earned.

 Is the malware currently active?

According David Kennedy, cyber security consultant formerly with the NSA, who looked in to the original program says that software is outdated now and it is not harming any PC at the moment.

How to avoid these type of situations?

These types of situations are really rare, but can happen any time. I will give you some suggestion to be prepared defend this type of situation.

  1. No matter what, always keep a backup somewhere in external resource that is not connected to internet.
  2. keep your computer up to date, always make sure to install all the security update released by the operating system.
  3. Beware of what you execute from your emails and popups.
  4. Use good Antivirus software. (It will slowdown your PC but it will prevent you from being a victim)
  5. Learn and use Linux, because most of these virus effect only Microsoft Operating system.

Hope this article will help you. please leave your comments and suggestion below. Thank you 🙂

Calico QR- code System

Calico is a Sri Lankan company  that manufacture Cords and tapes. Their main customers are Adidas and Nike, company’s manufacturing plant is located at Negombo,  Sri Lannka. Recently they approached us to develop a QR-Code generating  software for their packing section. Which they can put it on their boxes  and access the QR-code using their mobile to get entire details  about the package eg: contents, current location and invoice.

We were able to complete this project successfully, within few weeks. To accomplish this task we used technologies such as PHP, Mysql, HTML, CSS and Javascript. For Qr-code generating process, i used a third party library called phpqrcode developed by Alexandre Assouad, you can check his librarys at github-account.

Here is the code snippet for adding phpqrcode library.

Hope this Helps. 🙂