Swiftpack.co - MessageKit/MessageKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by MessageKit.
MessageKit/MessageKit 4.0.0
A community-driven replacement for JSQMessagesViewController
⭐️ 5,314
🕓 10 weeks ago
iOS
.package(url: "https://github.com/MessageKit/MessageKit.git", from: "4.0.0")

A community-driven replacement for JSQMessagesViewController

Xcode MIT Contributions Welcome


Goals

  • Provide a :rotating_light:safe:rotating_light: environment for others to learn and grow through Open Source.
  • Make adding Chat:speech_balloon: to a project easy.
  • Enable beautiful and customizable Chat UI's.
  • Provide an awesome Open Source project for the iOS open source community.
  • Help others learn.

Installation

Swift Package Manager - Recommended

Swift 5.3 in Xcode 12 added support for assets in Swift Packages. You can just add MessageKit package to your project by entering it's repository URL

https://github.com/MessageKit/MessageKit

Older versions of Swift and Xcode don't support MessageKit via SPM.

Manual

Requirements

  • iOS 13 or later
  • Swift 5.5 or later

For iOS 12 or CocoaPods please use version 3.8.0

For iOS 11 please use version 3.3.0

For iOS 9 and iOS 10 please use version 3.1.1

Getting Started

Please have a look at the Quick Start guide and the FAQs.

We recommend you start by looking at the Example project or write a question with the "messagekit" tag on Stack Overflow. You can also look at previous issues here on GitHub with the "Question" tag.

For more on how to use the MessageInputBar, see the dependency it is based on InputBarAccessoryView. You can also see this short guide

Check out the full documentation here.

Cell Structure

Each default cell is a subclass of MessageContentCell which has 7 parts. From top down we have a: cellTopLabel, messageTopLabel, messageContainerView, messageBottomLabel, cellBottomLabel with the avatarView and accessoryView on either side respectively. Above we see the basic TextMessageCell which uses a MessageLabel as its main content.

This structure will allow you to create a layout that suits your needs as you can customize the size, appearance and padding of each. If you need something more advanced you can implement a custom cell, which we show how to do in the Example project.

InputBarAccessoryView Structure

The InputBarAccessoryView, 3rd party dependency from InputBarAccessoryView is a flexible and robust way of creating any kind of input layout you wish. Check the repo and examples there for more info.

Default Cells

The type of cell rendered for a given message is based on the MessageKind

public enum MessageKind {
    case text(String) // TextMessageCell
    case attributedText(NSAttributedString) // TextMessageCell
    case photo(MediaItem) // MediaMessageCell
    case video(MediaItem) // MediaMessageCell
    case location(LocationItem) // LocationMessageCell
    case emoji(String) // TextMessageCell
    case audio(AudioItem) // AudioMessageCell
    case contact(ContactItem) // ContactMessageCell
    case linkPreview(LinkItem) // LinkPreviewMessageCell

    /// A custom message.
    /// - Note: Using this case requires that you implement the following methods and handle this case:
    ///   - MessagesDataSource: customCell(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> UICollectionViewCell
    ///   - MessagesLayoutDelegate: customCellSizeCalculator(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> CellSizeCalculator
    case custom(Any?)
}

If you choose to use the .custom kind you are responsible for all of the cells layout. Any UICollectionViewCell can be returned for custom cells which means any of the styling you provide from the MessageDisplayDelegate will not effect your custom cell. Even if you subclass your cell from MessageContentCell. Read more about custom cells

Read more about the cases on the Quick Start guide.

Contributing

Tests Build framework Build example app Danger

Great! Look over these things first.

  • Please read our Code of Conduct
  • Check the Contributing Guide Lines.
  • Come join us on Slack and 🗣 don't be a stranger.
  • Check out the current issues and see if you can tackle any of those.
  • Download the project and check out the current code base. Suggest any improvements by opening a new issue.
  • Check out the What's Next section :point_down: to see where we are headed.
  • Check StackOverflow
  • Install SwiftLint to keep yourself in :neckbeard: style.
  • Be kind and helpful.

What's Next?

Check out the Releases to see what we are working on next.

Contact

Have a question or an issue about MessageKit? Create an issue!

Interested in contributing to MessageKit? Click here to join our Slack.

Apps using this library

Add your app to the list of apps using this library and make a pull request.

Please provide attribution, it is greatly appreciated.

Core Team

Thanks

Many thanks to the contributors of this project.

License

MessageKit is released under the MIT License.

Inspiration

Inspired by JSQMessagesViewController :point_left: :100:

GitHub

link
Stars: 5314
Last commit: 6 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

4.0.0 - The King is dead, long live the King
10 weeks ago

iOS 12 has been around for a while, but with upcoming release of iOS 16, we are ready to let this version go and rest in peace forever. The same could be said about CocoaPods - what used to be the major and most important thing on iOS for developing apps with 3rd party libraries - has been replaced by natively supported way called Swift Package Manager.

Sit tibi terra levis.


Version 4.0.0 comes with couple of breaking changes, please refer to the MIGRATION_GUIDE.md for easy transition from V3 to V4.

Added

  • New method in MessagesLayoutDelegate for setting message avatar size ddfc814 by @martinpucik
  • MessageInputBarKind enum for customizing messageInputBar inside inputContainerView #1707 by @martinpucik

Changed

  • Breaking change: Dropped CocoaPods support
  • Breaking change: Dropped support for iOS 12 2bd234b by @martinpucik
  • Breaking change: Moved messageInputBar from inputAccessoryView to a subview in MessagesViewController #1704 by @martinpucik
  • Breaking change: Renamed func currentSender() -> SenderType to var currentSender: SenderType #1714 by @martinpucik
  • Deprecation: Deprecated maintainPositionOnKeyboardFrameChangedMoved in favor of maintainPositionOnInputBarHeightChanged which better describes the intended use of this property #1704 by @martinpucik
  • Breaking change: Added an argument to messageContainerMaxWidth cd4f75b by @martinpucik
    MessageSizeCalculator.messageContainerMaxWidth(for message: MessageType) -> CGFloat
    
    now has IndexPath argument
    MessageSizeCalculator.messageContainerMaxWidth(for message: MessageType, at indexPath: IndexPath) -> CGFloat
    
  • Breaking change: Added an argument to messageContainerSize cd4f75b by @martinpucik
    MessageSizeCalculator.messageContainerSize(for message: MessageType) -> CGSize
    
    now has IndexPath argument
    MessageSizeCalculator.messageContainerSize(for message: MessageType, at indexPath: IndexPath) -> CGSize
    
  • Updated InputBarAccessoryView to v6.1.0 #1716 by @martinpucik
  • Observe inputBar frame change to update collectionView bottom inset instead of keyboard show/hide notifications #1726 by @martinpucik

Fixed

  • Fixed iOS 13 deprecation warnings #1715 by @kaspik
  • Updating bottom chat collectionView inset after InputBar container view frame change #1725 by @martinpucik

Removed

  • NSConstraintLayoutSet.swift #1700 by @martinpucik
  • Deprecated Sender struct. Clients should use SenderType protocol #1713 by @martinpucik
  • Unavailable MessageInputBar and MessageInputBarDelegate. Clients should use InputBarAccessoryView and InputBarAccessoryViewDelegate #1713 by @martinpucik
  • func scrollToBottom(animated:) on MessagesCollectionView. Clients should use func scrollToLastItem(:) #1713 by @martinpucik

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