App Context API for Unity SDK
Starting a new app? Use DataSync
DataSync is the successor to App Context. It covers the same users, channels, and memberships, and adds typed schemas, JSON Patch updates with ETags, field-level projections, and per-class expiry. Refer to the feature-by-feature comparison for details.
DataSync is currently available to new accounts and to accounts that are not actively using App Context. If your keysets already use App Context, keep using it for now. App Context remains fully supported.
This page describes App Context (formerly Objects v2). To upgrade from Objects v1, refer to the migration guide.
App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.
PubNub also triggers events when object data is changed: set, updated, or removed from the database. Making a request to set the same data that already exists doesn't trigger an event. Clients can receive these events in real time and update their front-end application accordingly.
User
Manage UUID metadata: list, fetch, set, and remove. Include only the fields you need to reduce payload size.
Get metadata for all users
Get a paginated list of UUID metadata. Use filters and sorting to narrow results.
Required keyset configuration
Method(s)
To Get All UUID Metadata you can use the following method(s) in the Unity SDK:
1pubnub.GetAllUuidMetadata()
2 .IncludeCustom(bool)
3 .IncludeCount(bool)
4 .Page(PNPageObject)
5 .Sort(List<string>)
6 .Filter(string)
7 .Limit(int)
8 .Execute(System.Action<PNGetAllUuidMetadataResult, PNStatus>)
IncludeCustom#- Whether to include the Custom object in the response.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNGetAllUuidMetadataResult.ExecuteAsync#- Returns
Task<PNResult<PNGetAllUuidMetadataResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3using UnityEngine;
4
5public class GetAllUuidMetadataExample : MonoBehaviour {
6 // Reference to a pubnub manager previously setup in Unity Editor
7 // For more details, see https://www.pubnub.com/docs/sdks/unity#configure-pubnub
8 [SerializeField] private PNManagerBehaviour pubnubManager;
9
10 private async void Start() {
11 // Getting a reference to the Pubnub instance
12 var pubnub = pubnubManager.pubnub;
13
14 // Note that you can also initialize Pubnub instance for Unity directly from code:
15 /*
show all 49 linesResponse
1{
2 "Uuids": [
3 {
4 "Uuid": "uuid-1",
5 "Name": "John Doe",
6 "Email": "jack@twitter.com",
7 "ExternalId": null,
8 "ProfileUrl": null,
9 "Custom": null,
10 "Updated": "2020-06-17T16:28:14.060718Z"
11 },
12 {
13 "Uuid": "uuid-2",
14 "Name": "Bob Cat",
15 "Email": "bobc@example.com",
show all 29 linesGet user metadata
Fetch metadata for a single UUID. Include the Custom object if you need custom fields.
Method(s)
To Get UUID Metadata you can use the following method(s) in the Unity SDK:
1pubnub.GetUuidMetadata()
2 .Uuid(string)
3 .IncludeCustom(bool)
4 .Execute(System.Action<PNGetUuidMetadataResult, PNStatus>)
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 33 linesResponse
1{
2 "Uuid": "uuid-1",
3 "Name": "John Doe",
4 "Email": "jack@twitter.com",
5 "ExternalId": null,
6 "ProfileUrl": null,
7 "Custom": null,
8 "Updated": "2020-06-17T16:28:14.060718Z"
9}
Set user metadata
Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- Set the entire updated custom object.
Set metadata for a UUID in the database, including the Custom object. Use the eTag to avoid overwriting concurrent updates.
Method(s)
To Set UUID Metadata you can use the following method(s) in the Unity SDK:
1pubnub.SetUuidMetadata()
2 .Uuid(string)
3 .Name(string)
4 .Email(string)
5 .ExternalId(string)
6 .ProfileUrl(string)
7 .Custom(Dictionary<string, object>)
8 .IncludeCustom(bool)
9 .IfMatchesEtag(string)
10 .Execute(System.Action<PNSetUuidMetadataResult, PNStatus>)
Uuidrequired#- Unique user identifier. If not supplied then current user's
Uuidis used. Namerequired#- Display name for the user.
Email#- The user's email address.
ExternalId#- User's identifier in an external system.
ProfileUrl#- The URL of the user's profile picture.
Custom#- Custom JSON values. Can be strings, numbers, or booleans. App Context filtering language doesn’t support filtering by custom properties.
IfMatchesEtag#- Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.
IncludeCustom#- Whether to include the Custom object in the response.
Executerequired#System.Actionof typePNSetUuidMetadataResult.ExecuteAsync#- Returns
Task<PNResult<PNSetUuidMetadataResult>>.
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 29 linesResponse
1{
2 "Uuid": "uuid-1",
3 "Name": "John Doe",
4 "Email": "jack@twitter.com",
5 "ExternalId": null,
6 "ProfileUrl": null,
7 "Custom": null,
8 "Updated": "2020-06-17T16:28:14.060718Z"
9}
Remove user metadata
Removes the metadata from a specified UUID.
Method(s)
To Remove UUID Metadata you can use the following method(s) in the Unity SDK:
1pubnub.RemoveUuidMetadata()
2 .Uuid(string)
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 26 linesResponse
1{}
Channel
Manage channel metadata: list, fetch, set, and remove.
Get metadata for all channels
Get a paginated list of channel metadata. Use filters and sorting to narrow results.
Required keyset configuration
Method(s)
To Get All Channel Metadata you can use the following method(s) in the Unity SDK:
1pubnub.GetAllChannelMetadata()
2 .IncludeCustom(bool)
3 .IncludeCount(bool)
4 .Page(PNPageObject)
5 .Sort(List<string>)
6 .Filter(string)
7 .Execute(System.Action<PNGetAllChannelMetadataResult, PNStatus>)
IncludeCustom#- Whether to include the Custom object in the response.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Executerequired#System.Actionof typePNGetAllChannelMetadataResult.ExecuteAsync#- Returns
Task<PNResult<PNGetAllChannelMetadataResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 28 linesResponse
1{
2 "Channels": [
3 {
4 "Channel": "my-channel",
5 "Name": "My channel",
6 "Description": "A channel that is mine",
7 "Custom": null,
8 "Updated": "2020-06-17T16:52:19.562469Z"
9 },
10 {
11 "Channel": "main",
12 "Name": "Main channel",
13 "Description": "The main channel",
14 "Custom": {
15 "public": true,
show all 26 linesGet channel metadata
Fetch metadata for a single channel. Include the Custom object if you need custom fields.
Method(s)
To Get Channel Metadata you can use the following method(s) in the Unity SDK:
1pubnub.GetChannelMetadata()
2 .Channel(string)
3 .IncludeCustom(bool)
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 29 linesResponse
1{
2 "Channel": "my-channel",
3 "Name": "My channel",
4 "Description": "A channel that is mine",
5 "Custom": null,
6 "Updated": "2020-06-17T16:52:19.562469Z"
7}
Set channel metadata
Unsupported partial updates of custom metadata
The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- Set the entire updated custom object.
Set metadata for a channel in the database, including the Custom object. Use the eTag to avoid overwriting concurrent updates.
Method(s)
To Set Channel Metadata you can use the following method(s) in the Unity SDK:
1pubnub.SetChannelMetadata()
2 .Channel(string)
3 .Name(string)
4 .Description(string)
5 .Custom(Dictionary<string, object>)
6 .IncludeCustom(bool)
7 .IfMatchesEtag(string)
8 .Execute(System.Action<PNSetChannelMetadataResult, PNStatus>)
Channelrequired#- Channel name.
Name#- Name of a channel.
Description#- Description of a channel.
Custom#- Custom JSON values. Can be strings, numbers, or booleans. App Context filtering language doesn’t support filtering by custom properties.
IncludeCustom#- Whether to include the Custom object in the response.
IfMatchesEtag#- Use the eTag from an applicable get metadata call to ensure updates only apply if the object hasn’t changed. If the eTags differ, the server returns HTTP 412.
Executerequired#System.Actionof typePNSetChannelMetadataResult.ExecuteAsync#- Returns
Task<PNResult<PNSetChannelMetadataResult>>.
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 32 linesResponse
1{
2 "Channel": "my-channel",
3 "Name": "John Doe",
4 "Description": "sample description",
5 "Custom": {
6 "color": "blue"
7 },
8 "Updated": "2020-06-17T16:52:19.562469Z"
9}
Other examples
Iteratively update existing metadata
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 71 linesRemove channel metadata
Removes the metadata from a specified channel.
Method(s)
To Remove Channel Metadata you can use the following method(s) in the Unity SDK:
1pubnub.RemoveChannelMetadata()
2 .Channel(string)
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 28 linesResponse
1{}
Channel memberships
Manage the channels a UUID belongs to: list, set, remove, and manage in bulk.
Get channel memberships
List channel memberships for a UUID. This doesn't return subscriptions.
Method(s)
To Get Memberships you can use the following method(s) in the Unity SDK:
1pubnub.GetMemberships()
2 .Uuid(string)
3 .Include(PNMembershipField[])
4 .IncludeCount(bool)
5 .Page(PNPageObject)
6 .Execute(System.Action<PNGetMembershipsResult, PNStatus>)
Uuidrequired#- Unique user identifier. If not supplied then current user's
Uuidis used. Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Executerequired#System.Actionof typePNGetMembershipsResult.ExecuteAsync#- Returns
Task<PNResult<PNGetMembershipsResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 30 linesResponse
1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 linesSet channel memberships
Replace or add memberships for a UUID. Provide channels (optionally with custom data).
Method(s)
To Set Memberships you can use the following method(s) in the Unity SDK:
1pubnub.SetMemberships()
2 .Uuid(string)
3 .Channels(List<PNMembership>)
4 .Include(PNMembershipField[])
5 .IncludeCount(bool)
6 .Page(PNPageObject)
7 .Sort(List<string>)
8 .Filter(string)
9 .Limit(int)
10 .Execute(System.Action<PNMembershipsResult, PNStatus>)
Uuidrequired#- Unique user identifier. If not supplied then current user's
Uuidis used. Channelsrequired#- List of memberships to set. Accepts channel names or PNMembership objects (with optional custom data).
Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNMembershipsResult.ExecuteAsync#- Returns
Task<PNResult<PNMembershipsResult>>.
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
PNMembership
Channelrequired#- The name of the channel associated with this membership.
Custom#- A dictionary that stores custom metadata related to the membership, allowing for additional context or information.
Status#- The status of the membership, for example: "active" or "inactive"
Type#- The type of membership for categorization purposes.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 36 linesResponse
1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 linesRemove channel memberships
Remove memberships for a UUID. Provide the channels to remove.
Method(s)
To Remove Memberships you can use the following method(s) in the Unity SDK:
1pubnub.RemoveMemberships()
2 .Uuid(string)
3 .Channels(List<string>)
4 .Include(PNMembershipField[])
5 .IncludeCount(bool)
6 .Page(PNPageObject)
7 .Sort(List<string>)
8 .Filter(string)
9 .Limit(int)
10 .Execute(System.Action<PNMembershipsResult, PNStatus>)
Uuid#- Unique user identifier. If not supplied then current user's
Uuidis used. Channelsrequired#- Channels to remove from membership.
Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNMembershipsResult.ExecuteAsync#- Returns
Task<PNResult<PNMembershipsResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 36 linesResponse
1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 linesManage channel memberships
Add and remove memberships for a UUID in one request.
Method(s)
To Manage Memberships you can use the following method(s) in the Unity SDK:
1pubnub.ManageMemberships()
2 .Uuid(string)
3 .Set(List<PNMembership>)
4 .Remove(List<string>)
5 .Include(PNMembershipField[])
6 .IncludeCount(bool)
7 .Page(PNPageObject)
8 .Sort(List<string>)
9 .Execute(System.Action<PNMembership, PNStatus>)
Uuidrequired#- Unique user identifier. If not supplied then current user's
Uuidis used. Set#- Set channel memberships for the user.
Remove#- Remove channel memberships for the user.
Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Executerequired#System.Actionof typePNMembership.ExecuteAsync#- Returns
Task<PNResult<PNMembership>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 44 linesResponse
1{
2 "Memberships": [
3 {
4 "ChannelMetadata": {
5 "Channel": "my-channel",
6 "Name": "My channel",
7 "Description": "A channel that is mine",
8 "Custom": null,
9 "Updated": "2020-06-17T16:55:44.632042Z"
10 },
11 "Custom": {
12 "starred": false
13 },
14 "Updated": "2020-06-17T17:05:25.987964Z"
15 },
show all 38 linesChannel members
Manage the users in a channel: list, set, and remove.
Get channel members
List users in a channel. Include user metadata if needed.
Method(s)
To Get Channel Members you can use the following method(s) in the Unity SDK:
1pubnub.GetChannelMembers()
2 .Channel(string)
3 .Include(PNChannelMemberField[])
4 .IncludeCount(bool)
5 .Page(PNPageObject)
6 .Sort(List<string>)
7 .Filter(string)
8 .Limit(int)
9 .Execute(System.Action<PNChannelMembersResult, PNStatus>)
Channelrequired#- Channel name.
Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNChannelMembersResult.ExecuteAsync#- Returns
Task<PNResult<PNChannelMembersResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 30 linesResponse
1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 linesSet channel members
Set users in a channel. Provide UUIDs (optionally with custom data).
Method(s)
To Set Channel Members you can use the following method(s) in the Unity SDK:
1pubnub.SetChannelMembers()
2 .Channel(string)
3 .Uuids(List<PNChannelMember>)
4 .Include(PNChannelMemberField[])
5 .Page(PNPageObject)
6 .Sort(List<string>)
7 .Filter(string)
8 .Limit(int)
9 .Execute(System.Action<PNChannelMembersResult, PNStatus>)
Channelrequired#- Channel name.
Uuidsrequired#- List of members to add to the
channel. List can contain strings (Uuids only) or objects (which can include custom data). Include#- Whether to include additional fields.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNChannelMembersResult.ExecuteAsync#- Returns
Task<PNResult<PNChannelMembersResult>>.
API limits
To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 37 linesResponse
1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 linesRemove channel members
Remove users from a channel. Provide the UUIDs to remove.
Method(s)
To Remove Channel Members you can use the following method(s) in the Unity SDK:
1pubnub.RemoveChannelMembers()
2 .Channel(string)
3 .Uuids(List)
4 .Include(PNChannelMembersInclude[])
5 .IncludeCount(bool)
6 .Page(PnPageObject)
7 .Sort(List)
8 .Filter(string)
9 .Limit(int)
10 .Execute(System.Action<PNChannelMembersResult, PNStatus>)
Channelrequired#- Channel name.
Uuidsrequired#- Members to remove from channel.
Include#- Whether to include additional fields.
IncludeCount#- Whether to include the total count in the paginated response. Default is false.
Page#- Cursor-based pagination.
Sort#- Sort by
id,name,updatedwithasc/desc(for example,{name: 'asc'}). Limit#- Number of objects to return. Default/Max: 100.
Executerequired#System.Actionof typePNChannelMembersResult.ExecuteAsync#- Returns
Task<PNResult<PNChannelMembersResult>>.
Sample code
1using PubnubApi;
2using PubnubApi.Unity;
3
4// Configuration
5PNConfiguration pnConfiguration = new PNConfiguration(new UserId("myUniqueUserId"))
6{
7 SubscribeKey = "demo",
8 PublishKey = "demo",
9 Secure = true
10};
11
12// Initialize PubNub
13Pubnub pubnub = PubnubUnityUtils.NewUnityPubnub(pnConfiguration);
14
15// If you're using Unity Editor setup you can get the Pubnub instance from PNManagerBehaviour
show all 37 linesResponse
1{
2 "ChannelMembers": [
3 {
4 "UuidMetadata": {
5 "Uuid": "uuid-1",
6 "Name": "John Doe",
7 "Email": "jack@twitter.com",
8 "ExternalId": "",
9 "ProfileUrl": "",
10 "Custom": null,
11 "Updated": "2019-02-20T23:11:20.89375"
12 },
13 "Custom": {
14 "role": "admin"
15 },
show all 39 lines