Reputation: 18271
I am developing a chat app which sends emssages through push notifications and p2p connections (not via SMS or e-mail).
I would like to make a view controller which has some custom views at the top and then the messages thread below it. The messages should be presented in a manner similar to Messages
iPhone app.
Is it possible to reuse Apple code (is there a ViewController / View I can use? Can I somehow use MFMessageComposeViewController
?) or should I reinvent the wheel and make my own implementation?
Upvotes: 5
Views: 5362
Reputation: 3304
I have recently released an open source project that solves this exact problem. The Chat SDK is available under the MIT license on Github. The library has the following features that you may find useful:
BChatViewController.m
Speech bubble message view similar to the Messages app. Here you can also see examples of how to handle keyboard show and hide events to add the text input box on top of the keyboard.
BMessageCell.m
This is the main message bubble class. Here there are functions to dynamically color message bubbles (+(UIImage *) bubbleWithImage: withColor:
) and to add a speech bubble tail.
BMessageLayout.m
Useful utility functions to determine the height for a text area.
BTextInputView.m
This a resizable text input box that floats above the keyboard.
The user interface is very modular which means that you should be able to add it to your app relatively easily.
This library also supports Firebase out of the box which would mean that you wouldn't need to build your own system to send messages using push notifications.
Upvotes: 1
Reputation: 3068
There are several open-source solutions that re-create the messages interface rather accurately:
Of course, you could also create the interface yourself by using a UITableView to house custom cells that would draw the speech bubbles, and text inside them.
Upvotes: 8
Reputation: 367
UICollectionViewController could be used to create a messages like UI.
Upvotes: 1