Forward messages

Forward messages between channels to share information or facilitate collaboration.

Use Forward() on a message object or ForwardMessage() on a channel object. Both produce the same result with different input parameters.

Additional info in the forwarded message

Forwarded messages include originalPublisher (original sender's user ID) and originalChannelId (source channel ID).

Method signature​

These methods take the following parameters:

  • Forward()

    1message.Forward(string channelId)
  • ForwardMessage()

    1channel.ForwardMessage(Message message)

Input​

channelId#
Type: string
Default: no default
Unique identifier of the channel to which you want to forward the message. You can forward a message to the same channel on which it was published or to any other.
Required in Forward()
Yes
Required in ForwardMessage()
No
message#
Type: Message
Default: no default
Message object that you want to forward to the selected channel.
Required in Forward()
No
Required in ForwardMessage()
Yes

Output​

An awaitable Task.

Sample code​

Forward a message from the support channel to the incident-management channel.

  • Forward()

    1using System.Threading.Tasks;
    2using PubnubApi;
    3using PubnubChatApi;
    4using UnityEngine;
    5
    6// Configuration
    7PubnubChatConfig chatConfig = new PubnubChatConfig();
    8
    9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
    10{
    11 SubscribeKey = "demo",
    12 PublishKey = "demo",
    13 Secure = true
    14};
    15
    show all 40 lines
  • ForwardMessage()

    1using System.Threading.Tasks;
    2using PubnubApi;
    3using PubnubChatApi;
    4using UnityEngine;
    5
    6// Configuration
    7PubnubChatConfig chatConfig = new PubnubChatConfig();
    8
    9PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
    10{
    11 SubscribeKey = "demo",
    12 PublishKey = "demo",
    13 Secure = true
    14};
    15
    show all 49 lines

Was this page useful?

Last updated on