Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

Unreleased

1.8.3

Changed

Added

1.8.2 - 2019-12-09

Fixed

1.8.1 - 2019-08-06

Fixed

1.8.0 - 2019-08-01

Added

1.7.3 - 2019-07-19

Fixed

1.7.2 - 2019-07-18

Fixed

1.7.1 - 2019-07-17

Fixed

1.7.0 - 2019-07-01

Added

1.6.0 - 2019-06-24

1.5.3 - 2019-06-24

1.5.2 - 2019-06-11

Fixed

1.5.1 - 2019-05-28

Fixed

1.5.0 - 2019-04-24

Added

1.4.4 - 2019-04-01

### Fixed

1.4.3 - 2019-03-20

Fixed

1.4.2 - 2019-03-20

Fixed

1.4.1 - 2019-03-12

Fixed

1.4.0 - 2019-03-08

Added

Deprecated

1.3.1 - 2019-03-05

Fixed

1.3.0 - 2019-01-25

Added

Fixed

Removed

1.2.3 - 2018-12-21

Fixed

1.2.2 - 2018-12-19

Fixed

1.2.1 - 2018-11-30

Added

1.2.0 - 2018-11-30

Added

1.1.0 - 2018-11-29

Added

Removed

1.0.0 - 2018-10-29

Changed

Breaking

Removed

Added

0.10.3 - 2018-09-10

Fixed

Changed

0.10.2 - 2018-08-22

Added

0.10.1 - 2018-08-21

Fixed

Changed

0.10.0 - 2018-08-09

Changed

Added

0.9.0 - 2018-06-14

Changed

0.8.4 - 2018-05-26

Fixed

0.8.3 - 2018-05-25

Fixed

0.8.2 - 2018-05-04

Changed

0.8.1 - 2018-04-24

Fixed

PR: #77 Authored by: @steve228uk

0.8.0 - 2018-04-19

Changed

0.7.2 - 2018-04-16

Fixed

0.7.1 - 2018-04-16

Fixed

0.7.0 - 2018-03-26

Added

Changed

Removed

0.6.4 - 2018-03-01

Changed

Fixed

0.6.3 - 2018-02-26

Changed

0.6.2 - 2018-02-26

Fixed

0.6.1 - 2018-02-26

Changed

Added

0.6.0 - 2018-02-16

Changed

Added

0.5.0 - 2018-01-26

Changed

Added

currentUser.sendMessage(
    roomId: roomId,
    text: "My message text"
) { messageId, err in
    guard err == nil else {
        print("Error sending message \(err!.localizedDescription)")
        return
    }
    print("Successfully sent message with ID: \(messageId!)")
}

Note that the room's ID is now required as a parameter, not the whole PCRoom object as was the case with addMessage

let imageName = Bundle.main.path(forResource: "dog", ofType: "jpg")
let imageURL = URL(fileURLWithPath: imageName!)

currentUser.sendMessage(
    roomId: roomId,
    text: "My message text",
    attachmentType: .fileURL(imageURL, name: "dog.jpg")
) { messageId, err in
    guard err == nil else {
        print("Error sending message \(err!.localizedDescription)")
        return
    }
    print("Successfully sent message with ID: \(messageId!)")
}

There are currently 3 different attachmentTypes supported, as described in the PCAttachmentType enum:

Here's an example of using the .link(_: String, type: String) attachment type:

currentUser.sendMessage(
    roomId: roomId,
    text: "My message text",
    attachmentType: .link("https://i.giphy.com/RpByGPT5VlZiE.gif", type: "image")
) { messageId, err in
    guard err == nil else {
        print("Error sending message \(err!.localizedDescription)")
        return
    }
    print("Successfully sent message with ID: \(messageId!)")
}
public struct PCAttachment {
    public let fetchRequired: Bool
    public let link: String
    public let type: String
}

If fetchRequired is true then it means that the attachment is stored on the Chatkit servers and you need to make a request to the Chatkit API to fetch a valid link. To do this you can use the fetchAttachment function that has been added to the PCCurrentUser class. You use that like this:

currentUser.fetchAttachment(attachmentLink) { fetchedAttachment, err in
    guard err == nil else {
        print("Error fetching attachment \(err!.localizedDescription)")
        return
    }

    print("Fetched attachment link: \(fetchedAttachment!.link)")
}

You can then use the fetchedAttachment.link to download the file, if you so wish.

currentUser.downloadAttachment(
    fetchedAttachment.link,
    to: myChosenDestination,
    onSuccess: { url in
        print("Downloaded successfully to \(url.absoluteString)")
    },
    onError: { error in
        print("Failed to download attachment \(error.localizedDescription)")
    },
    progressHandler: { bytesReceived, totalBytesToReceive in
        print("Download progress: \(bytesReceived) / \(totalBytesToReceive)")
    }
)

Here myChosenDestination is an object of type PCDownloadFileDestination. This is a type based on Alamofire's DownloadFileDestination. It lets you specify where you'd like to have the download stored (upon completion).

One option for creating a PCDownloadFileDestination is to use the PCSuggestedDownloadDestination function, which is again based on an Alamofire construct: DownloadRequest.suggestedDownloadDestination. You can provide it a PPDownloadOptions object which determines whether or not the process of moving the downloaded file to the specified destination should be allowed to remove any existing files at the same path and if it should be able to create any required intermediate directories. This is expressed as an OptionSet with the following options:

public typealias PCHTTPTokenProvider = PPHTTPEndpointTokenProvider
public typealias PCTokenProviderRequest = PPHTTPEndpointTokenProviderRequest
public typealias PCLogger = PPLogger
public typealias PCLogLevel = PPLogLevel
public typealias PCDefaultLogger = PPDefaultLogger
public typealias PCDownloadFileDestination = PPDownloadFileDestination
public typealias PCDownloadOptions = PPDownloadOptions
public typealias PCRetryStrategy = PPRetryStrategy
public typealias PCDefaultRetryStrategy = PPDefaultRetryStrategy

public func PCSuggestedDownloadDestination(...) { return PPSuggestedDownloadDestination(...) }

This means that importing PusherPlatform should never need to be done anymore.

0.4.3 - 2018-01-09

Added

0.4.2 - 2018-01-06

Fixed

0.4.1 - 2017-11-01

Changed

0.4.0 - 2017-10-27

Changed

0.3.2 - 2017-10-25

Changed

0.3.1 - 2017-09-21

Added

0.3.0 - 2017-09-18

Added

Changed

0.2.9 - 2017-08-02

Changed

0.2.8 - 2017-08-01

Added

Changed

0.2.7 - 2017-07-28

Fixed

0.2.6 - 2017-07-26

Changed

0.2.5 - 2017-07-19

Changed

0.2.4 - 2017-07-18

Changed

0.2.3 - 2017-07-17

Removed

0.2.2 - 2017-06-29

Added

0.2.0 - 2017-06-21