Build

How to Build a Swift Chat App with iOS Chat Components

3 min readChandler Mayo on Mar 18, 2022
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

In this tutorial, we will walk you through how PubNub iOS Chat Components are used in an existing sample app.

This video will cover PubNub’s iOS Chat Components and how to integrate them into any other iOS app. This video is a continuation of our previous iOS Chat Components Release: Build Mobile Chat Experiences Tutorial. However, instead of starting from scratch we’ll take a second look at how iOS Chat Components work and some additional improvements we made.

We’ll start by taking a look at how PubNub iOS Chat Components have been integrated into an existing sample app. Then, we’ll show you how to configure and customize the components. If you’re not yet familiar with PubNub’s iOS Chat Components, check out our product release announcement here.

Let’s dive into the tutorial—watch below to see a demo of PubNub’s iOS Chat Components and learn about how your app can benefit from them, then keep reading to see how you can get your FREE API keys so you can start building with these components.  

PubNub’s iOS Chat Components Overview 

PubNub’s iOS Chat Components empower all kinds of developers to create dynamic chat experiences – without the time spent building chat when you could be focused on creating other parts of your application. If you are making a chat app from scratch, migrating your chat widget, or adding features to your existing iOS application—our ready-to-use iOS message components provide you with the building blocks to easily add the features your users expect from a chat experience. There’s no need to create and maintain the infrastructure yourself.

Our set of iOS Chat Components are packed with the features you’d expect from any chat experience:

  • User and Channel Metadata: Fetch metadata about users, channels, and memberships from objects storage using custom hooks.

  • Channel Subscription Management: Automatic subscriptions to current channel and optional subscriptions to other channels and channel groups.

  • Messages: Publish and listen to text messages and fetch history for each channel.

  • User Presence: Fetch currently present users and listen to new presence events like a user subscribing or leaving.

  • Typing Indicators: Typing indicators displayed as text notifications or messages.

  • Persistent Data Storage: Store messages, channels, and users locally for offline use.

Our iOS Chat Components are modifiable to your requirements so you’re free to create chat for various use cases all with different functionalities and customizable looks.

How do PubNub’s iOS Chat Components work?

PubNub is used for real-time message delivery, metadata, user presence, and other chat related data to facilitate the actions within the chat UI Components. iOS Chat Components have PubNub services fully incorporated and are ready to use.

The following chat components are included with PubNub iOS Chat Components:

  • MemberList: List of users with properties like names, titles, or avatars.

  • MessageList: List of messages with sender details.

  • MessageInput: Field to send messages to chat rooms. When you type this component also triggers typing indicators for other users.

  • ChannelList: List of channels that represents chat rooms in the application. We won’t be using this component in this tutorial. However, it’s easy to include if it’s necessary in your application.

Chat API Setup for iOS Components

To follow along with our tutorial, you will need a PubNub account, where you will use your PubNub API keys to build a chat application with iOS Chat Components. As a reminder, a PubNub account and API keys are always free.

Here’s how to get started: 

  1. Sign up for a PubNub account.

  2. Sign in to your PubNub Dashboard.

  3. Follow the steps in the video tutorial to configure a chat application with PubNub iOS Chat Components.

What’s Next 

In the above video tutorial, we took a look at how PubNub’s iOS Components are used in an existing Swift app and how to get started setting up a PubNub Account. 

The Weather-Chat app with PubNub iOS Chat Components we build can be found in this repo.

Continue by exploring these additional iOS Chat Components features:

Need some extra help or want to learn more about iOS Chat Components? Get in touch with our sales team to discuss how you can easily build and scale your chat with PubNub.

More from PubNub

Can Empathy Exist in the Metaverse
News May 16, 20221 min read

Can Empathy Exist in the Metaverse

A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.

PubNub Staff

PubNub Staff

How to Advance Telehealth and Virtual Care Technologies
News May 2, 20221 min read

How to Advance Telehealth and Virtual Care Technologies

Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...

PubNub Staff

PubNub Staff

Another Step Towards Data Security: ISO-27001 Implementation
BuildMay 2, 20221 min read

Another Step Towards Data Security: ISO-27001 Implementation

Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.

PubNub Staff

PubNub Staff