Build an iOS chat app that can communicate cross-platform

This tutorial will guide you through downloading, building and running the telehealth chat demo for iOS.  You will then optionally make some basic changes to the app.  Don’t worry if you have little or no iOS experience because this tutorial is aimed at all levels but if you are comfortable with Xcode, you might want to clone the code and skim this step.

PubNub supports HIPAA, GDPR, SOC2 type 2, and CCPA compliance enabling you to build telemedicine applications.

1

Prerequisites

You’ll need the following before you begin: 

  • Xcode, any recent version.  Xcode is available from the web or the app store and you’ll need to be using a Mac

  • Git (optional).  The source code for this demo is hosted in GitHub and git is a popular tool to obtain the source but other options exist such as downloading it as a zip.

Obtaining the Source Code

The Telehealth demo app for iOS is available from https://github.com/pubnub/chat-components-ios-examples.  This patient-doctor chat application uses PubNub’s Chat Components, which are pre-built UI and data building blocks to quickly create functional and visually appealing chat apps.

You can either:

Launch Xcode and from the welcome screen select ‘Clone an existing project’.

Welcome screen of Xcode with options to create a new project, clone an existing project highlighted, or open a project or file, on a Mac computer.

Then when prompted to enter the repository URL, enter the following:

1

Or you can invoke the git tool from a terminal to clone the source code.  Navigate to an empty folder and enter the following command:

1

Or if you would rather download the source code as a zip file, click on the ‘Code’ button on GitHub and select ‘Download ZIP’.  You will need to unzip the file before you can load the source.

GitHub repository interface showing options for cloning and downloading with the 'Download ZIP' button highlighted.

Other options exist, GitHub is very flexible :)

Open the code in Xcode

If you do not already have the project loaded, launch Xcode then select File → Open.

Select the directory where the telehealth source code is located and open ‘Examples.xcworkspace.

Integrated development environment interface showing package dependencies for a telehealth application project.

Open the TelehealthChatProvider.swift file which can be found within the Telehealth → PubNub folder (part of the telehealth-example workspace).  Notice towards the top of the file you need to define the following:

  • PUBNUB_PUB_KEY

  • PUBNUB_SUB_KEY

Computer screen with code from a telehealth chat provider service in an Integrated Development Environment (IDE).

You are not ready to run the application until you obtain those PubSub keys, so that is the next step.

BackStep 1 of 4Next