A smooth, responsive and flexible messages UI library for iOS.

Overview

AsyncMessagesViewController

A smooth, responsive and flexible messages UI library for iOS apps. Built on top of the awesome Texture (formerly AsyncDisplayKit) framework, it takes full advantage of asynchronous layout and rendering to deliver a "butter smooth" scrolling experience.

Screenshot1    Screenshot2

Dependencies

Requirements

  • iOS 9 and later.
  • Swift 4.
  • ARC.

Installation

From CocoaPods:

pod 'AsyncMessagesViewController'  

Without CocoaPods

Copy the Source\ directory to your project and install all dependencies.

How to use

  • Example project
    • Run pod install.
    • Open AsyncMessagesViewController.xcworkspace.
    • Enjoy the simple ViewController.swift class.
  • Model
    • Your message model object should conform to MessageData protocol.
  • View
    • MessageCellNode is your friend. Most of the time you don't want to subclass it.
    • There are 2 basic built-in bubble nodes implemented for you: MessageTextBubbleNode for text based messages and MessageNetworkImageBubbleNode for remote image based messages.
    • Need a custom bubble node? Here you go.
  • Controller
    • Your view controller should subclass AsyncMessagesViewController. As you may see, it's a very simple view controller (and should be). Most of the magic is in the data source.
    • What data source, you may ask. Any data source that conform to AsyncMessagesCollectionViewDataSource protocol.
    • There is a default implemention: DefaultAsyncMessagesCollectionViewDataSource. This class keeps a sorted list of messages, but doesn't allow you to change them directly. Instead, you must alter messages using given methods in its protocol and let it handle the heavy work. It can (supposedly) smartly determine which cells need to be inserted, deleted and reloaded. Why? because:
      • Calling reloadData is very expensive on ASCollectionView (and ASTableView).
      • Most of the time, inserting/deleting a cell causing UI changes in other cells as well. DefaultAsyncMessagesCollectionViewDataSource can detect those changes automatically.
    • MessageCellNodeMetadata provides runtime-computed information about a message and how its data should be presented in a MessageCellNode. Metadata of a message is often computed based on the relationship with other messages. For example, message's sender name should be displayed if it is an incoming message and is the first one in a set of consecutive messages sent by a same user. Or message's date should be shown if it is the first message sent within a 15 minutes window. This kind of UI logic is encapsulated in MessageCellNodeMetadataFactory and computed at runtime. Of course you can implement your own logic.

Customizations

  • Custom bubble node:
    • Please read this guide on subclassing ASDisplayNode.
    • Implement a factory that conforms to MessageBubbleNodeFactory protocol.
    • Inject your factory to DefaultAsyncMessagesCollectionViewDataSource via its initializer.
    • Inject the data source to AsyncMessagesViewController (also via its initializer).
  • Custom bubble image's colors:
    • Initiate a MessageBubbleImageProvider with whatever colors you want.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom bubble images:
    • Implementing your own MessageBubbleImageProvider.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom logic for computing cell metadata:
    • Subclass MessageCellNodeMetadataFactory and override any neccessary method.
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Custom format for message date:
    • Subclass MessageTimestampFormatter and override attributedTimestamp(NSDate).
    • Inject it to your data source.
    • Inject the data source to your view controller.
  • Any customization related to the input toolbar:
  • Other customizations:
    • File an issue and I will be more than happy to help :)

Contributing

All feedbacks, questions and pull requests are very welcome. See here for details.

Credits

Created by Huy Nguyen, an Android developer :)

License

AsyncMessagesViewController is released under an MIT License. See here for details.

Copyright © 2015 Huy Nguyen.

Comments
  • dude the example is not building

    dude the example is not building

    @nguyenhuy The example is SO outdated.... Clearly showing that this library is useless.. OMG I waisted time to fix errors, and in the end got error with .some lPods not found...

    You are worst programmer ever!!!

    opened by yarodevuci 7
  • Assertion failure in -[_ASCollectionViewProxy forwardingTargetForSelector:]

    Assertion failure in -[_ASCollectionViewProxy forwardingTargetForSelector:]

    Hi! Here is the scenario: my first view controller has an ASTableView containing some dummy cells for testing. Clicking either cell will push a new view controller named ChatViewController (which is exactly the ViewController from your example), with the exception that the collectionView scrolls to bottom after all the messages are inserted with success.

    dataSource.collectionView(collectionView, insertMessages: messages) { (success) -> () in
                if (success) {
                    self.scrollCollectionViewToBottom()
                }
            }
    

    After I click the back button, my app crashes giving this log: screen shot 2015-11-27 at 17 58 21

    If I scroll back to top in the ChatViewController and click the back button, the app will not crash. Is there any solution? Thank you!

    opened by StrauneanuDimitri 5
  • Roadmap

    Roadmap

    Hey @nguyenhuy!

    Terrific project. I'm excited. I've been thinking for some time now to build something similar but never managed to find time to actually write it, so congrats to you.

    Do you have a public roadmap or contributor guidelines?

    opened by FredericJacobs 4
  • Automatic scroll when TextView edit begins

    Automatic scroll when TextView edit begins

    I just noticed that when the chat view is at the bottom and I tap the input view, the chat view doesn't scroll up, and the last bubbles of chat get hidden by the keyboard view. When I tap outside the keyboard, the keyboard get dismissed but the chat scrolls back down with it, as if it had been scrolled up before and now "wants to get back" to its initial position. Though, when the chat view is not at the bottom, if I tap the input view, the chat does scroll up in a normal way, and when I tap outside the keyboard it scrolls back to its initial position. How can I fix the scroll behavior when the chat view is at the very bottom? Thank you.

    opened by modularthoughts 0
  • Unable to subclass AsyncMessagesViewController

    Unable to subclass AsyncMessagesViewController

    After installing the pod in XCode 9, I am unable subclass or otherwise use AsyncMessagesViewController. All other dependencies (SLKTextViewController, etc.) are accessible. I have deintegrated and reinstalled my pods. All other pods work.

    opened by swbrenneis 1
  • Ability to have sections

    Ability to have sections

    I have yet to find a message Library that will allow me to expand and collapse sections. I want to be able to pull in a "chat history" by date and somehow section it off by date. Thoughts?

    opened by justdan0227 0
  • Custom bubbles from UIView

    Custom bubbles from UIView

    Hey,

    First of all: Congrats for this awesome work! The first time I see AsyncDisplayKit I thought it would be awesome to have a chat library built on top of it.

    I don't have played enough with AsyncDisplayKit to being comfortable to adopt its sizing and designing techniques (i.e. without UIKit and Autolayout), and I'm have a deploy to do in the next days.

    I have a .xib within a UIView designed chat bubble I would like to port to AsyncMessagesViewController. Can I use the following method to inject my custom view into an ASDisplayNode and make it works with your library?

    let node = ASDisplayNode(viewBlock: { () -> UIView! in
        let view = SomeView();
        return view
    })
    

    (I've tried it, but I don't know if I'm doing something wrong or if it is not possible)

    Thank you in advance!

    opened by filipealva 0
Releases(0.1)
Owner
Huy Nguyen
iOS Software Engineer @pinterest, Core Contributor of Texture (formerly AsyncDisplayKit)
Huy Nguyen
OpenTok Text Chat Accelerator Pack enables text messages between mobile or browser-based devices.

Text Chat Accelerator Pack iOS This project is deprecated The OpenTok Text Chat Accelerator Pack for iOS project is now a part of Accelerator Core iOS

OpenTok 13 Jan 26, 2022
A very flexible message bar for iOS written in Swift.

A very flexible message bar for iOS written in Swift.

SwiftKick Mobile 6.7k Jan 5, 2023
Apple Push Notifications (APNs) Server-Side library.

Perfect-Notifications 简体中文 APNs remote Notifications for Perfect. This package adds push notification support to your server. Send notifications to iO

PerfectlySoft Inc. 113 Oct 28, 2022
MQTT for iOS and macOS written with Swift

CocoaMQTT MQTT v3.1.1 client library for iOS/macOS/tvOS written with Swift 5 Build Build with Xcode 11.1 / Swift 5.1 Installation CocoaPods Install us

EMQ X MQTT Broker 1.4k Dec 29, 2022
An XMPP Framework in Objective-C for Mac and iOS

XMPPFramework An XMPP Framework in Objective-C for the Mac and iOS development community. Abstract XMPPFramework provides a core implementation of RFC

Robbie Hanson 5.9k Dec 26, 2022
Scholarly Article Search, Discussion Forum and Discussion Board

DiscussIt An app to throughly explore vast database of scholarly article, choosing one to experiment with, discuss with your friends An Open Source Ap

Ethan 6 Jun 27, 2022
Open source, native iOS Messenger, with realtime chat conversations (full offline support).

OVERVIEW This is a native iOS Messenger app, with realtime chat conversations (full offline support). NEW FEATURES Passcode support GraphQL server sup

Related Code 4.5k Jan 9, 2023
Chat SDK iOS - Open Source Mobile Messenger

Chat SDK Open Source Messaging framework for iOS Chat SDK is a fully featured open source instant messaging framework for iOS. Chat SDK is fully featu

Chat SDK 879 Jan 6, 2023
Messenger Clone - Real-time iOS Chat with Firebase Firestore written in Swift

Real time Swift iOS Chat with Firebase - Messenger Clone This is an extremely simple chat app source code of an iOS Swift Chat app. It leverages Messa

Instamobile 621 Jan 6, 2023
Phantom Anonymous Messenger for iOS

?? Phantom for iOS This repository contains the complete source code of Phantom for iOS. Table of Contens ?? Report Bugs/Feature Requests/Security Iss

null 2 Mar 14, 2022
The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app.

The SwiftUI Messages Clone consists of layout and composition clones of the iOS Messages app. It has Messages-like bubble and screen effects, reactions, and animations, all created with SwiftUI.

Stream 20 Dec 24, 2022
IOS-PokemonQuizApp - Assignment to make a responsive iOS app. App has to connect with an external API

iOS-PokemonQuizApp Assignment to make a responsive iOS app. App has to connect with an external API. The Project The idea of the project is to make a

BennyDB 0 Jan 9, 2022
UICollectionViewSplitLayout makes collection view more responsive.

UICollectionViewSplitLayout makes collection view more responsive. What's this? UICollectionViewSplitLayout is a subclass of UICollectionViewLayout. I

Yahoo! JAPAN 239 Dec 6, 2022
Beautiful, responsive animations, when receiving notifications on jailbroken device

Notchification Beautiful, responsive animations, when receiving notifications on jailbroken device About Notification shows responsive, dynamic animat

c1d3r 5 Sep 15, 2022
UICollectionViewSplitLayout makes collection view more responsive.

UICollectionViewSplitLayout makes collection view more responsive. What's this? UICollectionViewSplitLayout is a subclass of UICollectionViewLayout. I

Yahoo! JAPAN 239 Dec 6, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles

A drop-in universal library helps you to manage the navigation bar styles and makes transition animations smooth between different navigation bar styles while pushing or popping a view controller for all orientations. And you don't need to write any line of code for it, it all happens automatically.

Zhouqi Mo 3.3k Dec 21, 2022
Library for smooth animation of images during transitions.

ImageTransition ImageTransition is a library for smooth animation of images during transitions. Something looks like below: e.g. UIImageView e.g. UIIm

shtnkgm 207 Dec 3, 2022
A Float Input View with smooth animation and supporting icon and seperator written with Swift

RSFloatInputView Features Smooth animation using CoreText Support optional left icon Support optional seperator Configurable padding, size, fonts and

null 103 Nov 13, 2022
Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Ethan Lipnik 89 Nov 29, 2022