Layer recently announced that they are ceasing all chat operations on October 30, 2019. Layer customers have just 3 months to migrate off their platform and implement another chat provider.
The good news is that several customers have easily moved off Layer onto PubNub, and we’ve got the resources at hand to make the move easy and fast for everyone else.
High-Level Differences
PubNub and Layer both enable you to build real-time messaging and other chat features into your application and provide the infrastructure to power it. That’s about where the similarities end.
Layer was an end-to-end chat solution for mobile and web that included backend infrastructure as well as UI/UX elements. Layer gave you a couple of tightly-defined ways to build chat as, by design, it’s more SaaS service than a framework. Its black box design approach accelerated the process of embedding chat functionality but left customers locked into their product, with UI/UX that is relatively rigid and tricky to customize.
PubNub provides an extensible, highly-customizable and globally-scaled real-time network for building the apps and features that make up a comprehensive connected experience. This means you can build not just chat apps of all shapes and sizes, but also geolocation tracking, notifications, dashboards, and more. PubNub is not a ‘widget’ service, which means the chat app itself has the flexibility to morph and innovate over time as your business sees fit.
How PubNub Enhances Your Layer App
Both PubNub and Layer empower you to deliver the table-stakes resources of chat: messaging, user management, typing indicators, unread message counts, and so forth, as well as backend infrastructure. It’s the advanced extensibility where the services differ greatly.
PubNub Serverless Functions
Layer Webhooks simply enabled responsiveness to events in a Layer chat app. This could be triggering automated responses (simple chatbots), notifying users when they are @mentioned, or adding in a weather bot powered by a 3rd party weather API.
With Functions, you can do more with your chat messages: transforming, mutating, and augmenting them in-motion, or integrating best-in-class 3rd party services within the chat room. This allows you to execute business logic at any point in the message delivery, and provide a faster and more efficient way to expand the capabilities of your chat application.
Infrastructure & Scale
Both services provide and maintain backend infrastructure, including managing SDKs, servers, and network. PubNub provides a 99.999% SLA, while Layer provides an SLA of 99.9% only. The two extra nines may seem redundant – but it is the difference between five minutes of annual downtime vs. five hundred minutes with Layer.
PubNub is designed for scale and supports any number of participants joining a single chatroom. One of our customers powered an interactive app to complement a massive, record-breaking international cricket tournament and had thousands of users in chat rooms
Security & User Management
Layer does not handle user management. It means that you cannot provide lists of users or limit actions to certain users (also known as “user permissions”). Instead, this functionality needs to be handled by the rest of your app and server.
PubNub is built with security in mind. PubNub’s Access Manager feature allows an application to enforce granular controls on the data that is accessible by each user. For instance, a limited user may be granted read-only permission on a channel, whereas a full user might be granted read-write permissions.
Mapping your Chat Features
Setting up the Chat Service
Layer uses appId to identify your account.
With PubNub, you can create an account and send up to 1M messages for free! You can get the publish key and subscribe key from your account and connect to the network. Some users may only need the subscribe key if they are allowed to receive messages, but not allowed to send messages.
Layer
var client = Layer.init({ appId: "layer:///apps/staging/YOUR-APP-ID", isTrustedDevice: false }); client.connect("Your-User-ID");
PubNub
const pubnub = new PubNub({ subscribeKey: 'YOUR_SUBKEY', publishKey: 'YOUR_PUBKEY', uuid: 'user123', });
Conversations vs. Channels
Layer Conversations and Channels need to be created with a set of participants before you can send messages. Conversations can have up to 25 participants, whereas Channels can have up to 250 participants.
PubNub is designed for scale and supports thousands of participants in a single channel. PubNub Channels are lightweight strings that merely exist by using them. Users can start receiving messages when they subscribe to one or many channels.
Layer
var conversation = client.createConversation({ participants: ['layer:///identities/UserA', 'layer:///identities/UserB'], distinct: false });
PubNub
pubnub.subscribe({ channels: ['room-1', 'room-2'], });
Sending Messages
Layer Message objects represent individual messages. They belong to a conversation and consist of one or more pieces of content, known as Message Parts. Messages can be text or base64-encoded data and are limited to 2KB in size.
PubNub supports sending messages with any serializable data; including objects, arrays, numbers, and strings. These messages can be used to send text-based communication, player movements in games, geolocation updates, sensor data, or anything you want. PubNub’s maximum size for a single message is 32 KB.
Layer
var message = conversation.createMessage({ parts: [{ body: 'Hi! How are you', mimeType: 'text/plain' }] }); message.send(); message.on('messages:sent', function() { myToast('Your message has been sent'); });
PubNub
var messageBody = { uuid: 'user123', text: 'Hello, hoomans!' } pubnub.publish({ message: messageBody, channel: 'room-1', }, (status, response) => { console.log('Your message has been delivered'); });
Developer Resources for Migration
Support
We’ve got customer success and support on-hand to assist you in your migration. Get in touch here.
Data Migration
Use PubNub REST APIs to migrate your chat messages into PubNub Storage.
Chat Documentation
Chat is at the heart of many of PubNub\’s core customer use cases. Our Chat Resource Center includes tutorials, design patterns, and education around building web and mobile chat apps with PubNub.