Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

pubnub/chat-engine-apple

Repository files navigation

Deprecation Notice

ChatEngine has been deprecated with no plans for additional releases. Support for the ChatEngine SDK will end on July 16, 2021. If you have questions about ChatEngine, please contact us at support@pubnub.com. Please visit our newer chat product, PubNub Chat.

This repository is a part of the ChatEngine Framework. For more information on building chat applications with PubNub, see our Chat Resource Center.

Build Status

Documentation

PubNub ChatEngine is an object oriented event emitter based framework for building chat applications in Objective-C. It reduces the time to build chat applications drastically and provides essential components like typing indicators, online presence monitoring and message history out of the box.

The real time server component is provided by PubNub. ChatEngine is designed to be extensible and includes a plugin framework to make adding new features simple.

Docs

You can find the full docs on the full documentation website. Concepts are linked below for convenience.

Concepts

  • Me - It's you dummy. The user that represents the current application.
  • Users and State - Explains how to interact with other users using ChatEngine and get additional information about them.
  • Chats - ChatEngine's bread and butter. These are isolated rooms that users can talk to each other in.
  • Events - Events are things that happen in a chat. Like message or image_upload for example.
  • Event Payload - The data that comes with an event. Includes things like who sent the event and what chat it was sent to.
  • Namespaces - ChatEngine has a lot of events, so we use name spacing to isolate them.
  • Wildcards - Get all the events of a single namespace, like $.online.* to get all types of online events.
  • Search - Retrieve old events that happened in the past. Usually done when your application boots up to show what happened before.
  • Global Chat - The chat that all users connect to. It's used for state management and application wide events.
  • Online List - Get all the users online in the chat room.
  • Authentication - How to use auth keys to identify your users and protect access to channels.
  • Privacy - Every user has a special feed chat that only they can publish to, and a direct chat that nobody else can read from. Outlines other ways of handling permissions as well.
  • Private Chats - Create private chats that nobody else can join.
  • Errors - Sometimes things don't go as planned, here's how you can catch errors gracefully.
  • Plugins - Drop in extra functionality, like emojii or typing indicators with plugins.
  • Building a Plugin - If what you need doesn't exist, it's easy to build yourself. Share it with us!
  • PubNub Functions - ChatEngine uses PubNub functions as a server component and details about that can be found here.
  • PubNub Channel Topology - Describes what PubNub channels ChatEngine is using under the hood.

Plugins

Uses UploadCare service to upload images and render them in chats.

Render Markdown in NSAttributedString when receiving messages.

Allows the current user to stop receiving events from other users.

A simple way to search through the list of users online in the chat.

Provides convenience methods that fire when a user starts or stops typing.

Allows you to mark a chat as being in the background and increments a counter as events are sent to it.

Uses images as fallback for devices that might not yet support 💩.

Emits additional events when someone reads a receives and/or reads a message.

Uses Gravatar service to create an avatar based on user state information.

A plugin that gives every use a random username combining a color and an animal.

Development

Setting up environment

It is required to install Xcode and CocoaPods on machine which will be used for application development. Perform following steps to complete environment preparation:

  1. Install Xcode from AppStore,
  2. After installation will be completed, launch Xcode and follow instruction to install command-line utilities,
  3. Install CocoaPods by running following command from Terminal:
    sudo gem install cocoapods
    

After completion of these steps you can start building your application.

Running Tests

You should complete environment setup before trying to build and run tests. At this moment there is 1198 tests in total (80 integration and 1118 unit tests). To run whole tests suite it will require ~11 minutes.

Xcode project for tests contains various build configurations, where particular type of tests can be chosen: unit, integration, unit with code coverage, integration with code coverage and all tests with code coverage.

To be able to run tests, follow next instruction:

  1. Clone repository:
    git clone git@github.com:pubnub/chat-engine-apple.git
    
  2. Navigate to Tests project directory:
    cd <path to clone location>/chat-engine-apple/Tests
    
  3. Install required dependencies (list of dependencies can be seen in Podfile):
    pod install
    
  4. After dependencies will be installed you should open project using ChatEngine Tests.xcworkspace file.
  5. At top left of opened window you should be able to find drop down list with following targets:
    • [Test] Code Coverage (Full)
    • [Test] Code Coverage (Integration)
    • [Test] Code Coverage (Unit)
    • [Test] iOS Integration
    • [Test] iOS Unit
  6. After desired target has been chosen, ensure what iPhone simulator (with blue background) is chosen for tests deployment.
  7. Hit shortcut Cmd+U to launch test suite.

Migration from 0.9.2 to 0.9.3

Events handler signature has been changed for better Swift support. From now on all events handler will receive only instance of CENEmittedEvent type.

Here is how handler looks like now:

self.client.me.direct.on(@"$.invite", ^(CENEmittedEvent *event) {
    NSDictionary *payload = ((NSDictionary *)event.data)[CENEventData.data];
    CENUser *sender = payload[CENEventData.sender];
    
    CENChat *secretChat = self.client.Chat().name(payload[@"channel"]).create();
});

Support

  • If you need help, have a general question, have a feature request or to file a bug, contact support@pubnub.com.