Swiftpack.co - parley-messaging/ios-library as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by parley-messaging.
parley-messaging/ios-library 3.8.0
Parley iOS app library
⭐️ 2
🕓 5 weeks ago
.package(url: "https://github.com/parley-messaging/ios-library.git", from: "3.8.0")

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.


Empty Conversation
Parley Parley


  • Chat: Send and receive text messages by using Parley.
  • Images and gifs: Send and receive images, including gifs, within the chat.
  • Messages with actions: Provide custom action buttons, allowing the user to choose from a set of actions.
  • Carousel messages: Sending carousel messages as an agent when using rich messaging.
  • Nested messages: Carousel messages support the same features as other messages inside the chat.
  • Answer Suggestions: Agents can provide reply suggestions for users when using rich messaging.
  • Custom styling: Fully change the styling of the chat to match your brand. All elements can be styled based on your preference.
  • Accessibility: Full support for VoiceOver and Dynamic Type for a more accessible experience.


  • iOS 12.0+
  • Xcode 14+
  • Swift 5+


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


Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler.

Once you have your Swift package set up, adding Parley as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "[email protected]:parley-messaging/ios-library.git", .upToNextMajor(from: "3.8.x"))


Checkout CHANGELOG.md for the latest changes and upgrade notes.

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.

Note: calling Parley.configure() twice is unsupported, make sure to call Parley.configure() only once for the lifecycle of 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.setPushToken(_:).


Other push types

Parley.setPushToken("pushToken", pushType: .customWebhook)
Parley.setPushToken("pushToken", pushType: .customWebhookBehindOAuth)
Parley.setPushToken("pushToken", pushType: .fcm) // Default

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. The certificate(s) should be added to your project.

You can use the certificates in this repository when using the default base url:

  • /Example/ParleyExample/Supported Files/_.parley.nu_29-Jul-2023.cer (Expires at: 29 Jul 2023)
  • /Example/ParleyExample/Supported Files/_.parley.nu_26-Jun-2023.cer (Expires at: 27 Jun 2024)

When a certificate is going to expire you can safely transition by adding the new .cer to the project. It is important to leave the old .cer in the app until after the new one is valid. In the next release the old certificate can be removed.

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.6/",
    apiVersion: .v1_6 // Must correspond to the same version in the path


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.6/",
    apiVersion: .v1_6,
    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: "[email protected]",
    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


Send a (silent) message

In some cases it may be handy to send a message for the user. You can easily do this by calling;

Parley.send("Lorem ipsum dolar sit amet")


It is also possible to send silent messages. Those messages are not visible in the chat.

Parley.send("User opened chat", silent: true)



Custom Unique Device Identifier

By default Parley uses a random UUID as device identifier which will be stored in the user defaults. This can be overridden by passing a custom uniqueDeviceIdentifier to the configure method:

Parley.configure("appSecret", uniqueDeviceIdentifier: "uniqueDeviceIdentifier")

When passing the uniqueDeviceIdentifier to the configure method, Parley will not store it. Client applications are responsible for storing it and providing Parley with the same ID in this case.


Parley doesn't need to be reset usually, but in some cases this might be wanted. For example when a user logs out and then logs in with a different account.

Resetting Parley will clear the current user information and chat data that is in memory. Requires calling the configure() method again to use Parley.




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: 2
Last commit: 5 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

5 weeks ago

IMPORTANT: Parley now has a minimum deployment target of iOS 12.0.

  • Added Dynamic Type support.
  • Added support for VoiceOver.
    • Read through the chat.
    • Interact with the chat.
    • Announcing received messages.
    • Fully supporting rich message types.
  • Added dismiss button to image viewer.
  • All icons now preserve vector data for a cleaner resolve.
  • Fixed an issue where the loading or typing indicator would not display in some cases.

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