Nishith Agarwal
Product Manager, PubNub
IN THIS ARTICLE

    Subscribe to Our Newsletter

    Stay updated with the latest on web, mobile, and IoT, delivered weekly.
    Thanks for subscribing!

    Thanks for subscribing!

    Get ready for some great content.

    Pusher Chatkit is Retiring

    Pusher announced this week that they are retiring their chat product, Pusher Chatkit, as of April 23, 2020. Unfortunately, this means that their customers have less than 30 days to migrate from Chatkit to another service to avoid disruptions to their app.

    For those of you looking to make the migration from Pusher Chatkit, we invite you to try out PubNub Chat as an alternative chat api that’s easy to build with, delivers the reliable and quality service you expect, and offers benefits above and beyond that.

    Engage your users right away with a fully featured, responsive, and well-designed chat application when you use PubNub Chat. Don’t just replace your chat -- take this opportunity to uplift your chat experience and better engage your customers with a chat they love.

    This guide will help you migrate your chat solution easily and continue to engage your customers with PubNub as your partner. While you focus on building the best experience for your customers, we take care of the heavy lifting like scalability, reliability, security, and global legislative compliance so that you don’t ever have to worry about whether your chat app is well-supported.

    Read on to see how you can easily migrate over from Pusher Chatkit, and how PubNub Chat will further enhance your chat experience.

    How PubNub Chat Enhances Your App

    1. Prebuilt Chat Features

    If you are migrating from Pusher, you presumably have already determined that building a chat application from scratch is time-consuming and can get rather complex. Instead of reinventing the wheel, you want to add core features to your applications quickly, so you can focus on your product. PubNub Chat comes preloaded with all the chat features that users expect from a modern-day chat experience.

    Compare the Pusher Chatkit feature set to that available in PubNub Chat: every feature you love in Pusher Chatkit is available in PubNub Chat. On top of that, PubNub offers additional features you like Message Reactions, Profanity Filters, Unlimited Concurrent Connections, and Unlimited Channels.

    Click here to see all features.

    2. Reliability at Scale

    Our network is built with security, scalability, and reliability at its core, so you can focus on creating the best experience while PubNub takes care of the rest. Deploy your unique chat solution on our trusted network that delivers realtime messages in less than 100ms, guarantees a 99.999% uptime SLA, and meets compliance needs for HIPAA, GDPR, and more. The network can scale up to support any number of concurrent users so you don’t have to limit engagement for users within your apps.

    3. Integrations and Customization

    With PubNub Chat, developers get full control and the flexibility to extend beyond the core service. PubNub Functions allow you to execute custom logic on the edge to transform in-flight messages as they go through the network. And if you have other custom development you’d like to include, PubNub Chat doesn’t lock you into a way of doing things, giving you complete control over the chat experience.

    You can choose from our collection of pre-built integrations with third-party services like Google Translate, Amazon Cognito, IBM Watson, Sift Ninja, SendGrid and others to bring content moderation, chatbots, language processing and other AI/ML capabilities to your chat apps in just a few minutes.

    4. Build More Realtime Features

    Chat applications are rarely stand-alone experiences and typically fit into the context of the wider communications in your app, including data flows, realtime updates, and notifications.   Our Realtime Communication Platform lets you start with a stellar chat experience now, and empowers you to extend to other realtime communication features like collaborations, notifications, live events, and geolocation all just as powerfully and all with PubNub.

    Mapping Pusher Chatkit to PubNub Chat for Your Migration

    Let’s hop into how you can actually migrate from Pusher Chatkit to PubNub Chat for all of your chat needs. Please note that the following shows how PubNub simplifies much of the logic that Pusher Chatkit requires. But, it is not a complete line-by-line guide. If you are planning a full migration, we highly recommend that you contact us so that an expert PubNub Solution Architect can walk you through in detail while you get started here.

    Connect with a User

    Pusher Chatkit requires you to spin up backend services to create users in their system before these users can connect from a client application.

    We value the privacy of your users and do not require them to be created if you already manage them externally. Users can directly connect from client applications without requiring any setup from a backend service.

    Pusher Chatkit:

    Create a user:

    const chatkit = new Chatkit.default({
      instanceLocator: "YOUR INSTANCE LOCATOR",
      key: "YOUR SECRET KEY"
    })
    
    chatkit.createUser({
      id: "bookercodes",
      name: "Alex Booker"
    })
    

    Connect with a user:

    const chatManager = new Chatkit.ChatManager({
        instanceLocator: "YOUR INSTANCE LOCATOR",
        userId: "YOUR USER ID",
        tokenProvider: tokenProvider
    });
    
    chatManager
        .connect()
        .then(currentUser => {
            console.log("Connected as user ", currentUser);
        })
        .catch(error => {
            console.error("error:", error);
        });
    

    PubNub Chat:

    const pubnub = new PubNub({
        subscribeKey: "YOUR SUBSCRIBE KEY",
        publishKey: "YOUR PUBLISH KEY",
        uuid: "YOUR USER ID"
    });
    

    Create and subscribe to a Room

    Pusher Chatkit requires you to explicitly create rooms before you can use them. Each room can only support up to 500 users.

    PubNub Chat uses lightweight strings called channels to deliver messages. Channels do not have to be defined in advance; they are automatically created by the act of publishing a message to the channel. Our service is designed for scale. It can support an unlimited number of channels and thousands of users in a single channel.

    Pusher Chatkit:

    Create a Room:

    currentUser.createRoom({
            id: '#general',
            name: 'General',
            private: true,
            addUserIds: ['craig', 'kate'],
            customData: {
                foo: 42
            },
        }).then(room => {
            console.log(`Created room called ${room.name}`)
        })
        .catch(err => {
            console.log(`Error creating room ${err}`)
        })
    

    Subscribe to Rooms:

    chatManager
        .connect()
        .then(currentUser => {
            currentUser.subscribeToRoomMultipart({
                roomId: currentUser.rooms[0].id,
                hooks: {
                    onMessage: message => {
                        console.log("Received message:", message)
                    }
                }
            });
        })
        .catch(error => {
            console.error("error:", error);
        })
    

    PubNub Chat:

    pubnub.addListener({
        status: function(statusEvent) {
            if (statusEvent.category === "PNConnectedCategory") {
                publishSampleMessage();
            }
        },
        message: function(msg) {
            console.log(msg.message.title);
            console.log(msg.message.description);
        }
    })
    pubnub.subscribe({
        channels: ['main']
    });
    

    Send a Message

    Pusher Chatkit allows users to send messages in a room by specifying a roomId. In the simplest case, you can send plain text messages with sendSimpleMessage or use sendMultipartMessage to send a message with an array of parts.

    The PubNub publish method enables users to send messages in a channel. These messages can contain any serializable data, including objects, arrays, numbers, and strings. In the simplest case, you can send a plain text message as string. For more complex cases, you can pass any object but JSON is usually the best choice.

    Pusher Chatkit:

    currentUser.sendSimpleMessage({
            roomId: myRoom.id,
            text: "Hi there!",
        })
        .then(messageId => {
            console.log(`Added message to ${myRoom.name}`)
        })
        .catch(err => {
            console.log(`Error adding message to ${myRoom.name}: ${err}`)
        })
    

    PubNub Chat:

    pubnub.publish({
            channel: 'main',
            message: 'Hello world'
        },
        function(status, response) {
            if (status.error) {
                console.log("publishing failed w/ status: ", status);
            } else {
                console.log("message published w/ response: ", response);
            }
        }
    );
    

    Fetch Messages in a Room

    Pusher Chatkit allows users to fetch older messages in a room. The method can be used to fetch missed messages by providing the messageId of the last message that was received by the app before it went offline. 

    PubNub’s storage feature in a similar way. The fetchMessages method allows you to fetch messages from multiple channels using a single call. These messages can be stored for a limited duration or permanently in our storage.

    Pusher Chatkit:

    currentUser.fetchMultipartMessages({
            roomId: someRoomId,
            initialId: 42,
            direction: 'older',
            limit: 10,
        })
        .then(messages => {
            // do something with the messages
        })
        .catch(err => {
            console.log(`Error fetching messages: ${err}`)
        })
    

    PubNub Chat:

    pubnub.fetchMessages({
            channels: ['ch-1','ch-2'],
            end: '15343325004275466'
        },
        (status, response) => {
            // handle response
        }
    );
    

    Next Steps & Resources

    Contact us now to migrate your chat service to PubNub. We aim to make it easy as your partner through this process.

    Our expert Solution Architects can guide you through the process and ensure that your migration is seamless, and that your app is built with best practices in mind. And once you’re running, our highly-rated Support team is there to make sure we can function as an extension of your operations and keep your chat experience in top shape.

    Visit our chat documentation to find sample code, reference guides, and tutorials to get started with PubNub Chat:

    More From PubNub