The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our

Please check if you can find an answer in our extensive documentation on Photon Chat.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

can i get Private chat history ?

2019-03-15 07:23:13

i need to private chat history in photon chat.
Is this possible? if yes then how and if no then why ?
please help me if any one have idea.

thank you.


2019-03-15 09:41:26

Hi @sonal_dhole2,

Where do you need the private chat history?
In client side or in chat webhooks?

What do you need the chat history for?

If user A sends private message(s) to user B while user B is disconnected, user B will receive the last X messages once connected as long as user A is still connected.
I think X is 100, it's the maximum history size per channel (private or public).

If this is not what you are looking for, you can always use public channels as "private channels": use special channel name (e.g. "-") and the channel can be subscribed only by two users (e.g. userA and user B ).

2019-03-19 11:35:05

i need private chat history in my room.
e.g. if two player A and B coming to single room and doing chat, after that player B left the room and again join the same room ,then i need the previous private chat of them.
is this possible ?

2019-03-19 14:16:54

Hi @sonal_dhole2,

Photon Chat has channels and does not have rooms.
Rooms are available in PUN or Photon Realtime.

The server keeps the last 100 messages exchanged per channel as long as player A or player B stay connected to Photon Chat.
The client API or SDK may cache the messages locally for more than 100 messages.
You can get those using:

string privateChannelName = chatClient.GetPrivateChannelNameByUser(remoteUser);  
ChatChannel privateChannel;  
if (chatClient.TryGetChannel(privateChannelName, true, out privateChannel))   
                List messages = privateChannel.Messages;  
                List senders = privateChannel.Senders;  

2019-04-09 11:17:19

i can't able to get private chat channel
chatClient.TryGetChannel(privateChannelName, true, out privateChannel)
at this point.

2019-04-17 12:02:35

Hi @sonal_dhole2,

This probably means that the client did not receive any message from that user.

2019-04-18 06:34:25

but in this method
public void OnPrivateMessage(string sender, object message, String channelName)
it receives the message then how can it possible?

2019-04-18 17:29:28

Hi @sonal_dhole2,

When are you using the code snippet?
At which point?

it receives the message then how can it possible?
Is the sender equal the local UserId? are you receiving your own message?

2019-04-22 07:29:04

Is the sender equal the local UserId?
it receives messages from both if the sender is a local user or another one.

are you receiving your own message?
receive messages of both of them who are in private chat.

my scenario is that

I am connected to chat client -----> chat with person as private chat -----> now I am disconnecting from chatclient ----> again connect to chat client and come online ------> at that time I can't get private chat history of with that person.

2019-04-22 13:26:51

Hi @sonal_dhole2,

it receives messages from both if the sender is a local user or another one. [...] receive messages of both of them who are in private chat.
Yes, that's the expected behaviour, if you send a private or public message you will also receive it yourself.

In file "Assets\Photon\PhotonChat\Code\ChatClient.cs", line 232, inside ChatClient.Connect, we clear private channels.


You can comment out this line and see if it helps.

Back to top