In this tutorial, you'll explore a group chat application for iOS using the PubNub Swift SDK. The application connects to a common chat room where users can exchange realtime messages over PubNub's Data Stream Network.
Download the code
You can get the full source code from GitHub. The code for this tutorial is in the
This tutorial requires the Presence and Storage & Playback add-ons. Refer to Create a PubNub app for detailed instructions.
A PubNub account. Sign up for PubNub and manage your projects from the Admin Dashboard.
Create a PubNub app
To create and configure a PubNub app for this tutorial, do the following:
Sign in to your PubNub Admin Dashboard, click Create New App, and give your app a name.
Select your new app, then click its keyset. Copy the Publish and Subscribe keys. You'll need these keys to include in your project.
Scroll down on the Key Options page and enable the Presence and Storage & Playback add-on features.
Click Save Changes, and you're done!
Run the project
To run the application in your local environment, do the following:
Set the following environment variables inside your terminal's configuration file (such as
Then, run the following commands from a Terminal window:
pod installhas completed, run the following command in your Terminal window:
Then, use the
Runcommand on the
AnimalForestChatscheme to build and execute the application on your physical device or the iOS simulator.
Explore the code
That's it! You should now have the app running in your local environment. To learn how we built the chat application, have a look at the Swift walkthrough.
To learn more, the reference section in the documentation includes code snippets for advanced features like typing indicators, unread message counts, security controls, chatbots, and more.