pusher / chatkit-client-js

JavaScript client SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
90 stars 15 forks source link

How do you create users? #87

Closed JamesDullaghan closed 6 years ago

JamesDullaghan commented 6 years ago

Using the node package, I'm not sure how to create a user. The documentation states to use Chatkit.default

screen shot 2018-07-15 at 12 17 28 am

I try to import Chatkit using:

import { Chatkit, ChatManager, TokenProvider } from '@pusher/chatkit'

But this doesn't work.

I try to call createUser on ChatManager, but this doesn't work either. This is in a react-native app and debugging is a bit more difficult for me here.

This is more of a question of if there is a correct way to create a user? If so, what is it? The example seems to be supplying a currentUser without creating one first.

In the source, when we call connect, it looks like it creates an instance of CurrentUser

https://github.com/pusher/chatkit-client-js/blob/master/src/chat-manager.js#L64

So why is the response I'm getting

The requested user does not exist. More information can be found at https://docs.pusher.com/errors/services/chatkit/not_found/user_not_found

Thanks for your time, and I'm guessing this is a documentation thing being as it's just a beta. Any response will be appreciated!

gianpaj commented 6 years ago

You need to create the user from your server. See: https://docs.pusher.com/chatkit/reference/server-node#creating-a-user https://docs.pusher.com/chatkit/quick_start/javascript#create-a-user

For example: https://github.com/pusher/chatkit-server-node/blob/master/examples/create_user.js https://github.com/pusher/chatkit-server-node (from this repo)

Also, make sure you read these articles to understand the architecture of how Chatkit works: https://docs.pusher.com/chatkit/core-concepts https://docs.pusher.com/chatkit/authentication

JamesDullaghan commented 6 years ago

Thank you very much for the help! Closing now.