Swiftpack.co -  Package - parley-messaging/ios-library
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Parley iOS app library
.package(url: "https://github.com/parley-messaging/ios-library.git", from: "3.1.3")

Parley Messaging iOS library

Easily setup a secure chat with the Parley Messaging iOS library. The Parley SDK allows you to fully customize the chat appearance and integrate it seamlessly in your own app for a great user experience.

Pay attention: You need an appSecret to use this library. The appSecret can be obtained by contacting Parley.


  • iOS 11.0+
  • Xcode 12+
  • Swift 5+


For remote notifications Parley relies on Google Firebase. Configure Firebase (using the installation guide) if you haven't configured Firebase yet.


Empty Conversation
Parley Parley


CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Parley into your Xcode project, specify it in your Podfile:

pod 'Parley', '~> 3.1.2'

Upgrading from 3.0.x to 3.1.0

3.1.0 contains a breaking change related to Public Key Pinning. Parley is not depending on TrustKit anymore.

Check out step 5 of the configuration to apply the new configuration.

Getting started

Follow the next steps to get a minimal setup of the library.

Step 1: Add the ParleyView to a ViewController

The ParleyView can be initialized manually or directly from the Storyboard.


Open the ViewController and add the following import:

import Parley

Create an instance of the Parley view (for example) in the viewDidLoad.

override func viewDidLoad() {

  let parleyView = ParleyView()
  parleyView.frame = self.view.frame



Add a view to the View Controller, select the Show the Identity inspector tab and change the Custom Class section to:

Class: ParleyView
Module: Parley

Step 2: Configure Parley

Configure Parley with your appSecret with Parley.configure(_ secret: String) (for example in your ViewController from step 1).


Replace appSecret by your Parley appSecret. The appSecret can be obtained by contacting Parley.

Step 3: Configure Firebase

Parley needs the FCM token to successfully handle remote notifications.

FCM Token

After retrieving an FCM token via your Firebase instance, pass it to the Parley instance in order to support remote notifications. This is can be done by using Parley.setFcmToken(_ fcmToken: String).


Handle remote notifications

Open your AppDelegate and add Parley.handle(_ userInfo: [AnyHashable: Any]) to the didReceiveRemoteNotification method to handle remote notifications.

extension AppDelegate : UNUserNotificationCenterDelegate {

    func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        _ = Parley.handle(userInfo)

    func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        if UIApplication.shared.applicationState == .active {
            completionHandler([]) // Do not show notifications when app is in foreground
        } else {
            completionHandler([.alert, .sound])

Step 4: Camera usage description

Add a camera and photo library usage description to the Info.plist file.

<string>We need access to the camera to take photos.</string>
<string>We need access to the photo library to select photos.</string>

Step 5: Add the certificate of the chat API

By default, Parley applies Public Key Pinning on every request executed to the chat api. In order to do you need to add the certificate to your project.

You can use the certificate in this repository when using the default base url (/Example/ParleyExample/Supported Files/*.parley.nu.cer).

More information about Public Key Pinning can be found on the website of OWASP.


Parley allows the usage of advanced configurations, such as specifying the network, specifying the user information or enabling offline messaging. In all use cases it is recommended to apply the advanced configurations before configuring the chat with Parley.configure(_ secret: String).


The network configuration can be set by setting a ParleyNetwork with the Parley.setNetwork(_ network: ParleyNetwork) method.

let network = ParleyNetwork(
    url: "https://api.parley.nu/",
    path: "clientApi/v1.2/",


Don't forget to add the right certificate to the project.

Custom headers

Custom headers can be set by using the optional parameter headers in ParleyNetwork. The parameter accepts a [String: String] Dictionary.

Note that the headers used by Parley itself cannot be overridden.

let headers: [String: String] = [
    "X-Custom-Header": "Custom header value"

let network = ParleyNetwork(
    url: "https://api.parley.nu/",
    path: "clientApi/v1.2/",
    headers: headers


User information

The chat can be identified and encrypted by applying an authorization token to the Parley.setUserInformation(_ authorization: String) method. The token can easily be generated on a secure location by following the Authorization header documentation.



Additional information

Additionally, you can set additional information of the user by using the additionalInformation parameter in Parley.setUserInformation() method. The parameter accepts a [String: String] Dictionary.


let additionalInformation = [
    kParleyAdditionalValueName: "John Doe",
    kParleyAdditionalValueEmail: "j.doe@parley.nu",
    kParleyAdditionalValueAddress: "Randstad 21 30, 1314, Nederland"

Parley.setUserInformation(authorization, additionalInformation: additionalInformation)

Clear user information


Offline messaging

Offline messaging can be enabled with the Parley.enableOfflineMessaging(_ dataSource: ParleyDataSource) method. ParleyDataSource is a protocol that can be used to create your own (secure) data source. In addition to this, Parley provides an encrypted data source called ParleyEncryptedDataSource which uses AES128 encryption.

if let key = "1234567890123456".data(using: .utf8), let dataSource = try? ParleyEncryptedDataSource(key: key) {

Disable offline messaging




Parley provides a ParleyViewDelegate that can be set on the ParleyView for receiving callbacks.

self.parleyView.delegate = self
extension ChatViewController: ParleyViewDelegate {

    func didSentMessage() {



Image upload is enabled by default.

self.parleyView.imagesEnabled = false


Parley provides a ParleyViewAppearance that can be set on the ParleyView to customize the chat appearance. ParleyViewAppearance can be initialized with a regular, italic and bold font which are customizable. Take a look at ChatViewController.swift for an example of how to use the ParleyViewAppearance.

let appearance = ParleyViewAppearance(fontRegularName: "Montserrat-Regular", fontItalicName: "Montserrat-Italic", fontBoldName: "Montserrat-Bold")

self.parleyView.appearance = appearance


Modern WhatsApp
Parley Parley


Parley is available under the MIT license. See the LICENSE file for more info.


Stars: 0
Last commit: 2 weeks ago

Release Notes

1 year ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco