App Context API for Objective- SDK
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 running your own databases.
PubNub also triggers events when object data changes: set, update, or removal. Setting the same data again doesn't trigger an event. Clients can receive these events in real time and update their front-end application accordingly.
User
Get metadata for all users
Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.
Required keyset configuration
Method(s)
To Get All UUID Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)allUUIDMetadataWithRequest:(PNFetchAllUUIDMetadataRequest *)request
2 completion:(PNFetchAllUUIDMetadataCompletionBlock)block;
PNFetchAllUUIDMetadataRequest
sort#- Sort by id, name, updated with asc/desc for sort direction (for example,
{name: 'asc'}). includeFields#- Bitfield of response fields. Supported:
PNUUIDTotalCountField(total count),PNUUIDCustomField(UUID custom),PNUUIDStatusField(UUID status),PNUUIDTypeField(UUID type). Default isPNUUIDTotalCountField(set 0 to reset). start#- Cursor-based pagination.
end#- Cursor-based pagination. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1#import <Foundation/Foundation.h>
2#import <PubNub/PubNub.h>
3
4// Basic configuration
5PNConfiguration *config = [PNConfiguration configurationWithPublishKey:@"demo"
6 subscribeKey:@"demo"
7 userID:@"metadataUser"];
8
9// Create a PubNub client instance
10PubNub *client = [PubNub clientWithConfiguration:config];
11
12// Example 1: Basic UUID metadata fetch
13NSLog(@"Fetching all UUID metadata...");
14
15// Create a basic request
show all 137 linesResponse
Response returned by the client for fetch all UUID metadata:
1@interface PNFetchAllUUIDMetadataData : PNServiceData
2
3// List of UUID metadata objects created for current subscribe key.
4@property (nonatomic, readonly, strong) NSArray<PNUUIDMetadata *> *metadata;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of objects created for current subscribe key.
14 *
15 * Value will be 0 in case if PNUUIDTotalCountField not added to 'includeFields'
show all 27 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet metadata for all users (builder pattern)
Required keyset configuration
Method(s)
1objects()
2 .allUUIDMetadata()
3 .includeFields(PNUUIDFields)
4 .includeCount(BOOL)
5 .filter(NSString *)
6 .sort(NSArray<NSString *> *)
7 .limit(NSUInteger)
8 .start(NSString *)
9 .end(NSString *)
10 .performWithCompletion(PNFetchAllUUIDMetadataCompletionBlock);
includeFields#- Bitfield of response fields. Supported:
PNUUIDTotalCountField(number of UUID metadata records),PNUUIDCustomField(custom set during UUID metadata set),PNUUIDStatusField(status set during UUID metadata set),PNUUIDTypeField(type set during UUID metadata set). Default isPNUUIDTotalCountField(set 0 to reset). includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- Sort by id, name, updated with asc/desc for sort direction (for example,
{name: 'asc'}). limit#- Number of objects to return. Default/Max: 100.
start#- Cursor-based pagination.
end#- Cursor-based pagination. Ignored if the
startparameter is supplied. blockrequired#- Associated
metadata fetchcompletion handler block.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().allUUIDMetadata()
2 .start(@"<next from previous request>")
3 .includeFields(PNUUIDCustomField)
4 .includeCount(YES)
5 .limit(40)
6 .performWithCompletion(^(PNFetchAllUUIDMetadataResult *result, PNErrorStatus *status) {
7 if (!status.isError) {
8 /**
9 * UUID metadata successfully fetched.
10 * Result object has following information:
11 * result.data.metadata - List of fetched UUID metadata.
12 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
13 * result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
14 * result.data.totalCount - Total number of created UUID metadata.
15 */
show all 24 linesResponse
Response returned by the client for fetch all UUID metadata:
1@interface PNFetchAllUUIDMetadataData : PNServiceData
2
3// List of UUID metadata objects created for current subscribe key.
4@property (nonatomic, readonly, strong) NSArray<PNUUIDMetadata *> *metadata;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of objects created for current subscribe key.
14 *
15 * Value will be 0 in case if PNUUIDTotalCountField not added to 'includeFields'
show all 27 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet user metadata
Returns metadata for the specified UUID, optionally including the custom data object for each.
Method(s)
To Get UUID Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)uuidMetadataWithRequest:(PNFetchUUIDMetadataRequest *)request
2 completion:(PNFetchUUIDMetadataCompletionBlock)block;
PNFetchUUIDMetadataRequest
includeFields#- Bitfield of response fields. Supported:
PNUUIDCustomField(custom set during UUID metadata set),PNUUIDStatusField(status set during UUID metadata set),PNUUIDTypeField(type set during UUID metadata set). uuid#- Create and configure fetch
UUIDmetadata request.uuid- Identifier for metadata should be fetched. Will be set to current PubNub configuration uuid if nil is set.
Sample code
1PNFetchUUIDMetadataRequest *request = [PNFetchUUIDMetadataRequest requestWithUUID:@"uuid"];
2// Add this request option, if returned metadata model should have value which has been set to
3// 'custom' property.
4request.includeFields = PNUUIDCustomField;
5
6[self.client uuidMetadataWithRequest:request
7 completion:^(PNFetchUUIDMetadataResult *result, PNErrorStatus *status) {
8
9 if (!status.isError) {
10 /**
11 * UUID metadata successfully fetched.
12 * Fetched UUID metadata information available here: result.data.metadata
13 */
14 } else {
15 /**
show all 22 linesResponse
Response returned by the client for fetch UUID metadata:
1@interface PNFetchUUIDMetadataData : PNServiceData
2
3// Requested UUID metadata object.
4@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;
5
6@end
7
8@interface PNFetchUUIDMetadataResult : PNResult
9
10// Fetch UUID metadata request processed information.
11@property (nonatomic, readonly, strong) PNFetchUUIDMetadataData *data;
12
13@end
Error response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet user metadata (builder pattern)
Method(s)
1objects()
2 .uuidMetadata()
3 .uuid(NSString *)
4 .includeFields(PNUUIDFields)
5 .performWithCompletion(PNFetchUUIDMetadataCompletionBlock);
uuid#- Identifier for which associated
metadatashould be fetched. Default: configured PubNub clientuuid includeFields#- Bitfield of response fields. Supported:
PNUUIDCustomField(custom set during UUID metadata set),PNUUIDStatusField(status set during UUID metadata set),PNUUIDTypeField(type set during UUID metadata set). blockrequired#Fetch UUID metadatarequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().uuidMetadata()
2 .uuid(@"uuid")
3 .includeFields(PNUUIDCustomField)
4 .performWithCompletion(^(PNFetchUUIDMetadataResult *result, PNErrorStatus *status) {
5 if (!status.isError) {
6 /**
7 * UUID metadata successfully fetched.
8 * Fetched UUID metadata information available here: result.data.metadata
9 */
10 } else {
11 /**
12 * Handle UUID metadata fetch error. Check 'category' property to find out possible issue
13 * because of which request did fail.
14 *
15 * Request can be resent using: [status retry]
show all 18 linesResponse
Response returned by the client for fetch UUID metadata:
1@interface PNFetchUUIDMetadataData : PNServiceData
2
3// Requested UUID metadata object.
4@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;
5
6@end
7
8@interface PNFetchUUIDMetadataResult : PNResult
9
10// Fetch UUID metadata request processed information.
11@property (nonatomic, readonly, strong) PNFetchUUIDMetadataData *data;
12
13@end
Error response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesSet 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, optionally including the custom data object for each.
Method(s)
To Set UUID Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)setUUIDMetadataWithRequest:(PNSetUUIDMetadataRequest *)request
2 completion:(nullable PNSetUUIDMetadataCompletionBlock)block;
PNSetUUIDMetadataRequest
custom#- Additional / complex attributes which should be associated with metadata. App Context filtering language doesn't support filtering by custom properties.
externalId#- Identifier from external service (database, auth service).
profileUrl#- URL at which profile available.
includeFields#- Bitfield of response fields. Supported:
PNUUIDCustomField(custom set during UUID metadata set),PNUUIDStatusField(status set during UUID metadata set),PNUUIDTypeField(type set during UUID metadata set). email#- Email address.
name#- Name which should be stored in metadata associated with specified identifier.
uuid#- Create and configure set UUID metadata request.
uuid- Identifier with which \c metadata is linked. Will be set to current PubNub configuration uuid if nil is set. status#- The custom status of the user.
type#- The custom type of the user.
ifMatchesEtag#- The entity tag to be used to ensure updates only happen if the object hasn't been modified since it was read. Use the eTag you received from an applicable get metadata method to check against the server entity tag. If the eTags don't match, an HTTP 412 error is thrown.
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
Sample code
1PNSetUUIDMetadataRequest *request = [PNSetUUIDMetadataRequest requestWithUUID:@"uuid"];
2// With this option on, returned metadata model will have value which has been set to 'custom'
3// property.
4request.includeFields = PNUUIDCustomField;
5request.custom = @{ @"age": @(39), @"status": @"Checking some stuff..." };
6request.email = @"support@pubnub.com";
7request.name = @"David";
8
9[self.client setUUIDMetadataWithRequest:request completion:^(PNSetUUIDMetadataStatus *status) {
10 if (!status.isError) {
11 /**
12 * UUID metadata successfully has been set.
13 * UUID metadata information available here: status.data.metadata
14 */
15 } else {
show all 23 linesResponse
Response returned by the client for set UUID metadata:
1@interface PNSetUUIDMetadataData : PNServiceData
2
3// Updated UUID metadata object.
4@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;
5
6@end
7
8@interface PNSetUUIDMetadataStatus : PNAcknowledgmentStatus
9
10// Set UUID metadata request processed information.
11@property (nonatomic, readonly, strong) PNSetUUIDMetadataData *data;
12
13@end
Set user metadata (builder pattern)
Method(s)
1objects()
2 .setUUIDMetadata()
3 .uuid(NSString *)
4 .name(NSString *)
5 .externalId(NSString *)
6 .profileUrl(NSString *)
7 .custom(NSDictionary *)
8 .email(NSString *)
9 .includeFields(PNUUIDFields)
10 .performWithCompletion(nullable PNSetUUIDMetadataCompletionBlock);
API limits
To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.
uuid#- Identifier with which new
metadatashould be associated. Default: configured PubNub clientuuid name#- Name which should stored in
metadataassociated with specifiedUUID. externalId#- External identifier (database, auth service) associated with specified
UUID. profileUrl#- External URL with information for specified
UUIDrepresentation. custom#- Additional information which should be stored in
metadataassociated with specifiedUUID. App Context filtering language doesn't support filtering by custom properties. email#- Email address which should be stored in
metadataassociated with specifiedUUID. includeFields#- Bitfield of response fields. Supported:
PNUUIDCustomField(custom set during UUID metadata set),PNUUIDStatusField(status set during UUID metadata set),PNUUIDTypeField(type set during UUID metadata set). block#Set UUID metadatarequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().setUUIDMetadata()
2 .uuid(@"uuid")
3 .name(@"Serhii")
4 .externalId(@"93FVfHUAf4RLu79J7Q3ejLVu")
5 .profileUrl(@"https://pubnub.com")
6 .custom(@{ @"age": @(36) })
7 .email(@"support@pubnub.com")
8 .includeFields(PNUUIDCustomField)
9 .performWithCompletion(^(PNSetUUIDMetadataStatus *status) {
10 if (!status.isError) {
11 /**
12 * UUID metadata successfully has been set.
13 * UUID metadata information available here: status.data.metadata
14 */
15 } else {
show all 23 linesResponse
Response returned by the client for set UUID metadata:
1@interface PNSetUUIDMetadataData : PNServiceData
2
3// Updated UUID metadata object.
4@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;
5
6@end
7
8@interface PNSetUUIDMetadataStatus : PNAcknowledgmentStatus
9
10// Set UUID metadata request processed information.
11@property (nonatomic, readonly, strong) PNSetUUIDMetadataData *data;
12
13@end
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 Objective-C SDK:
1- (void)removeUUIDMetadataWithRequest:(PNRemoveUUIDMetadataRequest *)request
2 completion:(nullable PNRemoveUUIDMetadataCompletionBlock)block;
PNRemoveUUIDMetadataRequest
uuid#- Create and configure delete user request.
identifier- Create and configure removeUUIDmetadata request. Will be set to current PubNub configuration uuid if nil is set.
Sample code
1PNRemoveUUIDMetadataRequest *request = [PNRemoveUUIDMetadataRequest requestWithUUID:@"uuid"];
2
3[self.client removeUUIDMetadataWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
4 if (!status.isError) {
5 // UUID metadata successfully removed.
6 } else {
7 /**
8 * Handle UUID metadata remove error. Check 'category' property to find out possible
9 * issue because of which request did fail.
10 *
11 * Request can be resent using: [status retry]
12 */
13 }
14}];
Response
Response returned by the client for remove UUID metadata:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesRemove user metadata (builder pattern)
Method(s)
1objects()
2 .removeUUIDMetadata()
3 .uuid(NSString *)
4 .performWithCompletion(PNFetchUUIDMetadataCompletionBlock);
5
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().removeUUIDMetadata()
2 .uuid(@"uuid")
3 .performWithCompletion(^(PNAcknowledgmentStatus *status) {
4 if (!status.isError) {
5 // User successfully deleted.
6 } else {
7 /**
8 * Handle user delete error. Check 'category' property to find out possible issue
9 * because of which request did fail.
10 *
11 * Request can be resent using: [status retry]
12 */
13 }
14 });
Response
Response returned by the client for remove UUID metadata:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesChannel
Get metadata for all channels
Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.
Required keyset configuration
Method(s)
To Get All Channel Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)allChannelsMetadataWithRequest:(PNFetchAllChannelsMetadataRequest *)request
2 completion:(PNFetchAllChannelsMetadataCompletionBlock)block;
PNFetchAllChannelsMetadataRequest
includeFields#- Bitfield of response fields. Supported:
PNChannelTotalCountField(number of channel metadata records),PNChannelCustomField(custom set during channel metadata set),PNChannelStatusField(status set during channel metadata set),PNChannelTypeField(type set during channel metadata set). Default isPNChannelTotalCountField(set 0 to reset). sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Cursor-based pagination. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1PNFetchAllChannelsMetadataRequest *request = [PNFetchAllChannelsMetadataRequest new];
2request.start = @"<next from previous request>";
3// Add this request option, if returned metadata models should have value which has been set to
4// 'custom' property.
5request.includeFields = PNUUIDCustomField | PNUUIDTotalCountField;
6request.limit = 40;
7
8[self.client allChannelsMetadataWithRequest:request
9 completion:^(PNFetchAllChannelsMetadataResult *result, PNErrorStatus *status) {
10 if (!status.isError) {
11 /**
12 * Channels metadata successfully fetched.
13 * Result object has following information:
14 * result.data.metadata - List of fetched channels metadata.
15 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
show all 26 linesResponse
Response returned by the client for fetch all UUID metadata:
1@interface PNFetchAllChannelsMetadataData : PNServiceData
2
3// List of channels metadata objects created for current subscribe key.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMetadata *> *metadata;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of objects created for current subscribe key.
14 *
15 * Value will be 0 in case if PNChannelTotalCountField not added to 'includeFields'
show all 27 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet metadata for all channels (builder pattern)
Method(s)
1objects()
2 .allChannelsMetadata()
3 .includeFields(PNChannelFields)
4 .includeCount(BOOL)
5 .filter(NSString)
6 .sort(NSArray)
7 .limit(NSUInteger)
8 .start(NSString)
9 .end(NSString)
10 .performWithCompletion(PNFetchChannelMetadataCompletionBlock);
includeFields#- Bitfield of response fields. Supported:
PNChannelTotalCountField(number of channel metadata records),PNChannelCustomField(custom set during channel metadata set),PNChannelStatusField(status set during channel metadata set),PNChannelTypeField(type set during channel metadata set). Default isPNChannelTotalCountField(set 0 to reset). includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- Sort by id, name, updated with asc/desc for sort direction (for example,
{name: 'asc'}). limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. blockrequired#Fetch all UUID metadatarequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().allChannelsMetadata()
2 .start(@"<next from previous request>")
3 .includeFields(PNChannelCustomField)
4 .includeCount(YES)
5 .limit(40)
6 .performWithCompletion(^(PNFetchAllChannelsMetadataResult *result, PNErrorStatus *status) {
7 if (!status.isError) {
8 /**
9 * Channels metadata successfully fetched.
10 * Result object has following information:
11 * result.data.metadata - List of fetched channels metadata.
12 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
13 * result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
14 * result.data.totalCount - Total number of associated channel metadata.
15 } else {
show all 23 linesResponse
Response returned by the client for fetch all UUID metadata:
1@interface PNFetchAllChannelsMetadataData : PNServiceData
2
3// List of channels metadata objects created for current subscribe key.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMetadata *> *metadata;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of objects created for current subscribe key.
14 *
15 * Value will be 0 in case if PNChannelTotalCountField not added to 'includeFields'
show all 27 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet channel metadata
Returns metadata for the specified Channel, optionally including the custom data object for each.
Method(s)
To Get Channel Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)channelMetadataWithRequest:(PNFetchChannelMetadataRequest *)request
2 completion:(PNFetchChannelMetadataCompletionBlock)block;
PNFetchChannelMetadataRequest
includeFields#- Bitfield of response fields. Supported:
PNChannelCustomField(custom set during channel metadata set),PNChannelStatusField(status set during channel metadata set),PNChannelTypeField(type set during channel metadata set). channel#- Create and configure fetch channel metadata request.
channel- Name of channel for which metadata should be fetched.
Sample code
1PNFetchChannelMetadataRequest *request = [PNFetchChannelMetadataRequest requestWithChannel:@"channel"];
2// Add this request option, if returned metadata model should have value which has been set to
3// 'custom' property.
4request.includeFields = PNChannelCustomField;
5
6[self.client channelMetadataWithRequest:request
7 completion:^(PNFetchChannelsMetadataResult *result, PNErrorStatus *status) {
8
9 if (!status.isError) {
10 /**
11 * Channel metadata successfully fetched.
12 * Channel metadata information available here: result.data.metadata
13 */
14 } else {
15 /**
show all 22 linesResponse
Response returned by the client for fetch channel metadata:
1@interface PNFetchChannelMetadataData : PNServiceData
2
3// Requested channel metadata object.
4@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;
5
6@end
7
8@interface PNFetchChannelsMetadataResult : PNResult
9
10// Fetch channel metadata request processed information.
11@property (nonatomic, readonly, strong) PNFetchChannelMetadataData *data;
12
13@end
Error response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet channel metadata (builder pattern)
Method(s)
1objects()
2 .channelMetadata(NSString *)
3 .includeFields(PNChannelFields)
4 .performWithCompletion(PNFetchChannelMetadataCompletionBlock);
channelrequired#- Name of channel for which associated
metadatashould be fetched. includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNChannelCustomField- include field with additional information from metadata which has been used during channel metadata set requests.PNChannelStatusField- include field withmetadatastatus which has been used duringchannel metadata setrequestsPNChannelTypeField- Include field withmetadatatype which has been used duringchannel metadata setrequests.
blockrequired#Fetch channel metadatarequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().channelMetadata(@"channel")
2 .includeFields(PNChannelCustomField)
3 .performWithCompletion(^(PNFetchChannelsMetadataResult *result, PNErrorStatus *status) {
4 if (!status.isError) {
5 /**
6 * Channel metadata successfully fetched.
7 * Channel metadata information available here: result.data.metadata
8 */
9 } else {
10 /**
11 * Handle channel metadata fetch error. Check 'category' property to find out possible
12 * issue because of which request did fail.
13 *
14 * Request can be resent using: [status retry]
15 */
show all 17 linesResponse
Response returned by the client for fetch channel metadata:
1@interface PNFetchChannelMetadataData : PNServiceData
2
3// Requested channel metadata object.
4@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;
5
6@end
7
8@interface PNFetchChannelsMetadataResult : PNResult
9
10// Fetch channel metadata request processed information.
11@property (nonatomic, readonly, strong) PNFetchChannelMetadataData *data;
12
13@end
Error response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesSet 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, optionally including the custom data object for each.
Method(s)
To Set Channel Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)setChannelMetadataWithRequest:(PNSetChannelMetadataRequest *)request
2 completion:(nullable PNSetChannelMetadataCompletionBlock)block;
PNSetChannelMetadataRequest
custom#- Additional / complex attributes which should be stored in metadata associated with specified channel. App Context filtering language doesn't support filtering by custom properties.
information#- Description which should be stored in metadata associated with specified channel.
includeFields#- Bitfield of response fields. Supported:
PNChannelCustomField(custom set during channel metadata set),PNChannelStatusField(status set during channel metadata set),PNChannelTypeField(type set during channel metadata set). name#- Name which should be stored in metadata associated with specified channel.
channel#- Create and configure set channel metadata request.
channel- Name of channel for which metadata should be set. status#- The custom status of the channel.
type#- The custom type of the channel.
ifMatchesEtag#- The entity tag to be used to ensure updates only happen if the object hasn't been modified since it was read. Use the eTag you received from an applicable get metadata method to check against the server entity tag. If the eTags don't match, an HTTP 412 error is thrown.
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
Sample code
1PNSetChannelMetadataRequest *request = [PNSetChannelMetadataRequest requestWithChannel:@"channel"];
2// Add this request option, if returned metadata model should have value which has been set to
3// 'custom' property.
4request.includeFields = PNChannelCustomField;
5request.custom = @{ @"responsibilities": @"Manage tests", @"status": @"offline" };
6request.name = @"Updated channel name";
7
8[self.client setChannelMetadataWithRequest:request completion:^(PNSetChannelMetadataStatus *status) {
9 if (!status.isError) {
10 /**
11 * Channel metadata successfully has been set.
12 * Channel metadata information available here: status.data.metadata
13 */
14 } else {
15 /**
show all 22 linesResponse
Response returned by the client for set channel metadata:
1@interface PNSetChannelMetadataData : PNServiceData
2
3// Associated channel's metadata object.
4@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;
5
6@end
7
8@interface PNSetChannelMetadataStatus : PNAcknowledgmentStatus
9
10// Set channel metadata request processed information.
11@property (nonatomic, readonly, strong) PNSetChannelMetadataData *data;
12
13@end
Other examples
Iteratively update existing metadata
1#import <Foundation/Foundation.h>
2#import <PubNub/PubNub.h>
3
4// Assume 'client' is an initialized PubNub instance as shown in previous examples.
5// PubNub *client = [PubNub clientWithConfiguration:config];
6
7NSString *channel = @"demo_example";
8NSString *initialName = @"Initial Channel Name";
9NSString *initialDescription = @"Initial channel description.";
10NSDictionary *initialCustom = @{ @"location": @"default_location" };
11
12// First, set some initial metadata for the channel
13PNSetChannelMetadataRequest *initialSetRequest = [PNSetChannelMetadataRequest requestWithChannel:channel];
14initialSetRequest.name = initialName;
15initialSetRequest.information = initialDescription;
show all 65 linesSet channel metadata (builder pattern)
Method(s)
1objects()
2 .setChannelMetadata(NSString *)
3 .includeFields(PNChannelFields)
4 .channel(NSString)
5 .name(NSString)
6 .information(NSString)
7 .custom(NSDictionary)
8 .performWithCompletion(PNFetchChannelMetadataCompletionBlock);
API limits
To learn about the maximum length of parameters used to set channel metadata, refer to REST API docs.
channelrequired#- Name of channel with which new
metadatashould be associated. name#- Name which should stored in
metadataassociated with specifiedchannel. information#- Description which should be stored in
metadataassociated with specifiedchannel. custom#- Additional information which should be stored in
metadataassociated with specifiedchannel. App Context filtering language doesn't support filtering by custom properties. includeFields#- Bitfield of response fields. Supported:
PNChannelCustomField(custom set during channel metadata set),PNChannelStatusField(status set during channel metadata set),PNChannelTypeField(type set during channel metadata set). block#Set channel metadatarequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().setChannelMetadata(@"channel")
2 .name(@"Admin")
3 .information(@"Administrative channel")
4 .custom(@{ @"responsibilities": @"Manage access to protected resources" })
5 .includeFields(PNChannelCustomField)
6 .performWithCompletion(^(PNSetChannelMetadataStatus *status) {
7 if (!status.isError) {
8 /**
9 * Channel metadata successfully has been set.
10 * Channel metadata information available here: status.data.metadata
11 */
12 } else {
13 /**
14 * Handle channel metadata update error. Check 'category' property to find out possible
15 * issue because of which request did fail.
show all 20 linesResponse
Response returned by the client for set channel metadata:
1@interface PNSetChannelMetadataData : PNServiceData
2
3// Associated channel's metadata object.
4@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;
5
6@end
7
8@interface PNSetChannelMetadataStatus : PNAcknowledgmentStatus
9
10// Set channel metadata request processed information.
11@property (nonatomic, readonly, strong) PNSetChannelMetadataData *data;
12
13@end
Remove channel metadata
Removes the metadata from a specified channel.
Method(s)
To Remove Channel Metadata you can use the following method(s) in the Objective-C SDK:
1- (void)removeChannelMetadataWithRequest:(PNRemoveChannelMetadataRequest *)request
2 completion:(nullable PNRemoveChannelMetadataCompletionBlock)block;
PNRemoveChannelMetadataRequest
channel#- Create and configure remove channel metadata request.
channel- Name of channel for which metadata should be removed.
Sample code
1PNRemoveChannelMetadataRequest *request = [PNRemoveChannelMetadataRequest requestWithChannel:@"channel"];
2
3[self.client removeChannelMetadataWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
4 if (!status.isError) {
5 // Channel metadata successfully removed.
6 } else {
7 /**
8 * Handle channel metadata remove error. Check 'category' property to find out possible
9 * issue because of which request did fail.
10 *
11 * Request can be resent using: [status retry]
12 */
13 }
14}];
Response
Response returned by the client for remove channel metadata:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesRemove channel metadata (builder pattern)
Method(s)
1objects()
2 .removeChannelMetadata(NSString *)
3 .performWithCompletion(nullable PNRemoveChannelMetadataCompletionBlock);
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().removeChannelMetadata(@"channel")
2 .performWithCompletion(^(PNAcknowledgmentStatus *status) {
3 if (!status.isError) {
4 // Channel metadata successfully removed.
5 } else {
6 /**
7 * Handle channel metadata remove error. Check 'category' property to find out possible
8 * issue because of which request did fail.
9 *
10 * Request can be resent using: [status retry]
11 */
12 }
13 });
Response
Response returned by the client for remove channel metadata:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNAcknowledgmentStatus : PNErrorStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesChannel memberships
Get channel memberships
The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.
Method(s)
To Get Memberships you can use the following method(s) in the Objective-C SDK:
1- (void)membershipsWithRequest:(PNFetchMembershipsRequest *)request
2 completion:(PNFetchMembershipsCompletionBlock)block;
PNFetchMembershipsRequest
sort#- Sort by id, name, updated with asc/desc for sort direction (for example,
{name: 'asc'}). includeFields#- Bitfield of response fields. Supported:
PNMembershipsTotalCountField(number of memberships),PNMembershipCustomField(custom set during membership set),PNMembershipStatusField(status set during membership set),PNMembershipTypeField(type set during membership set),PNMembershipChannelField(include channel metadata),PNMembershipChannelCustomField(channel custom set during channel metadata set),PNMembershipChannelStatusField(channel status set during channel metadata set),PNMembershipChannelTypeField(channel type set during channel metadata set). Default isPNMembershipsTotalCountField(set 0 to reset). start#- Cursor-based pagination.
end#- Cursor-based pagination. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1PNFetchMembershipsRequest *request = [PNFetchMembershipsRequest requestWithUUID:@"uuid"];
2request.start = @"<next from previous request>";
3// Add this request option, if returned membership models should have value which has been set to
4// 'custom' and 'channel' properties.
5request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
6request.limit = 40;
7
8[self.client membershipsWithRequest:request
9 completion:^(PNFetchMembershipsResult *result, PNErrorStatus *status) {
10
11 if (!status.isError) {
12 /**
13 * UUID's memberships successfully fetched.
14 * Result object has following information:
15 * result.data.memberships - List of UUID's memberships.
show all 28 linesResponse
Response returned by the client for fetch memberships:
1@interface PNFetchMembershipsData : PNServiceData
2
3// List of fetched memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of members created for current subscribe key.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet channel memberships (builder pattern)
Method(s)
1objects()
2 .memberships()
3 .uuid(NSString *)
4 .includeFields(PNMembershipFields)
5 .includeCount(BOOL)
6 .filter(NSString *)
7 .sort(NSArray<NSString *> *)
8 .limit(NSUInteger)
9 .start(NSString *)
10 .end(NSString *)
11 .performWithCompletion(PNFetchMembershipsCompletionBlock);
uuid#- Name of channel from which members should be fetched.
includeFields#- Bitfield of response fields. Supported:
PNMembershipsTotalCountField(number of memberships),PNMembershipCustomField(custom set during membership set),PNMembershipStatusField(status set during membership set),PNMembershipTypeField(type set during membership set),PNMembershipChannelField(include channel metadata),PNMembershipChannelCustomField(channel custom set during channel metadata set),PNMembershipChannelStatusField(channel status set during channel metadata set),PNMembershipChannelTypeField(channel type set during channel metadata set). Default isPNMembershipsTotalCountField(set 0 to reset). includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. blockrequired#Fetch UUID's membershipsrequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().memberships()
2 .uuid(@"uuid")
3 .includeCount(YES)
4 .limit(40)
5 .includeFields(PNMembershipCustomField | PNMembershipChannelField)
6 .performWithCompletion(^(PNFetchMembershipsResult *result, PNErrorStatus *status) {
7 if (!status.isError) {
8 /**
9 * UUID's memberships successfully fetched.
10 * Result object has following information:
11 * result.data.memberships - List of UUID's memberships.
12 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
13 * result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
14 * result.data.totalCount - Total number of UUID's memberships.
15 */
show all 24 linesResponse
Response returned by the client for fetch memberships:
1@interface PNFetchMembershipsData : PNServiceData
2
3// List of fetched memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of members created for current subscribe key.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesSet channel memberships
Set channel memberships for a UUID.
Method(s)
To Set Memberships you can use the following method(s) in the Objective-C SDK:
1- (void)setMembershipsWithRequest:(PNSetMembershipsRequest *)request
2 completion:(nullable PNManageMembershipsCompletionBlock)block;
PNSetMembershipsRequest
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
Sample code
1NSArray<NSDictionary *> *channels = @[
2 @{
3 @"channel": @"channel1",
4 @"status": @"active",
5 @"type": @"public",
6 @"custom": @{ @"role": @"moderator" }
7 }
8];
9
10PNSetMembershipsRequest *request = [PNSetMembershipsRequest requestWithUUID:@"uuid"
11 channels:channels];
12// Add this request option, if returned membership models should have value which has been set to
13// 'custom' and 'channel' properties.
14request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
15request.limit = 40;
show all 35 linesResponse
Response returned by the client for set memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesSet channel memberships (builder pattern)
Method(s)
1objects()
2 .setMemberships()
3 .uuid(NSString *)
4 .channels(NSArray<NSDictionary *> *)
5 .includeFields(PNMembershipFields)
6 .includeCount(BOOL)
7 .filter(NSString *)
8 .sort(NSArray<NSString *> *)
9 .limit(NSUInteger)
10 .start(NSString *)
11 .end(NSString *)
12 .performWithCompletion(nullable PNManageMembershipsCompletionBlock);
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
uuid#- Identifier for which memberships should be set. Default: configured PubNub client
uuid channels#- List of
channelsfor whichmetadataassociated with each of them in context ofUUIDshould be set. Each entry is dictionary withchannelandoptionalcustomfields.customshould be dictionary with simple objects:NSStringandNSNumber. includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Set UUID's membershipsrequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1NSArray<NSDictionary *> *channels = @[
2 @{
3 @"channel": @"channel1",
4 @"status": @"active",
5 @"type": @"public",
6 @"custom": @{ @"role": @"moderator" }
7 }
8];
9
10self.client.objects().setMemberships()
11 .uuid(@"uuid")
12 .channels(channels)
13 .includeCount(YES)
14 .limit(40)
15 .includeFields(NMembershipCustomField | PNMembershipChannelField)
show all 34 linesResponse
Response returned by the client for set memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesRemove channel memberships
Remove channel memberships for a UUID.
Method(s)
To Remove Memberships you can use the following method(s) in the Objective-C SDK:
1- (void)removeMembershipsWithRequest:(PNRemoveMembershipsRequest *)request
2 completion:(nullable PNManageMembershipsCompletionBlock)block;
PNRemoveMembershipsRequest
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1NSArray<NSString *> *channels = @[@"channel1", @"channel2"];
2PNRemoveMembershipsRequest *request = [PNRemoveMembershipsRequest requestWithUUID:@"uuid"
3 channels:channels];
4// Add this request option, if returned membership models should have value which has been set to
5// 'custom' and 'channel' properties.
6request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
7request.limit = 40;
8
9[self.client removeMembershipsWithRequest:request
10 completion:^(PNManageMembershipsStatus *status) {
11
12 if (!status.isError) {
13 /**
14 * UUID's memberships successfully removed.
15 * Result object has following information:
show all 29 linesResponse
Response returned by the client for remove memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesRemove channel memberships (builder pattern)
Method(s)
1objects()
2 .removeMemberships()
3 .uuid(NSString *)
4 .channels(NSArray<NSString *> *)
5 .includeFields(PNMemberFields)
6 .includeCount(BOOL)
7 .filter(NSString *)
8 .sort(NSArray<NSString *> *)
9 .limit(NSUInteger)
10 .start(NSString *)
11 .end(NSString *)
12 .performWithCompletion(nullable PNManageMembershipsCompletionBlock);
uuid#- Identifier for which memberships should be removed. Default: configured PubNub client
uuid channels#- List of
channelsfrom whichUUIDshould be removed asmember. includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Remove UUID's membershipsrequest completion block.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().removeMemberships()
2 .uuid(@"uuid")
3 .channels(@[@"channel1", @"channel2"])
4 .includeCount(YES)
5 .limit(40)
6 .includeFields(PNMembershipCustomField | PNMembershipChannelField)
7 .performWithCompletion(^(PNManageMembershipsStatus *status) {
8 if (!status.isError) {
9 /**
10 * UUID's memberships successfully removed.
11 * Result object has following information:
12 * status.data.memberships - List of UUID's existing memberships.
13 * status.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
14 * status.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
15 * status.data.totalCount - Total number of UUID's memberships.
show all 25 linesResponse
Response returned by the client for remove memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesManage channel memberships
The method Set and Remove channel memberships for a user.
Method(s)
To Manage Memberships you can use the following method(s) in the Objective-C SDK:
1- (void)manageMembershipsWithRequest:(PNManageMembershipsRequest *)request
2 completion:(nullable PNManageMembershipsCompletionBlock)block;
PNManageMembershipsRequest
setChannels#- List of channels within which UUID should be set as member. Each entry is dictionary with channel and optional
customfields.customshould be dictionary with simple objects: NSString and NSNumber. removeChannels#- List of channels from which UUID should be removed as member.
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1PNManageMembershipsRequest *request = [PNManageMembershipsRequest requestWithUUID:@"uuid"];
2request.setChannels = @[
3 @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
4];
5request.removeChannels = @[@"channel3", @"channel4"];
6// Add this request option, if returned membership models should have value which has been set to
7// 'custom' and 'channel' properties.
8request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
9request.limit = 40;
10
11[self.client manageMembershipsWithRequest:request
12 completion:^(PNManageMembershipsStatus *status) {
13
14 if (!status.isError) {
15 /**
show all 31 linesResponse
Response returned by the client for manage memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesManage channel memberships (builder pattern)
Method(s)
1objects()
2 .manageMemberships()
3 .uuid(NSString *)
4 .set(NSArray<NSDictionary *> *)
5 .remove(NSArray<NSString *> *)
6 .includeFields(PNMemberFields)
7 .includeCount(BOOL)
8 .filter(NSString *)
9 .sort(NSArray<NSString *> *)
10 .limit(NSUInteger)
11 .start(NSString *)
12 .end(NSString *)
13 .performWithCompletion(nullable PNManageMembershipsCompletionBlock);
uuid#- Identifier for which memberships should be set. Default: configured PubNub client
uuid set#- List of
channelsfor whichmetadataassociated with each of them in context ofUUIDshould be set. Each entry is dictionary withchannelandoptionalcustomfields.customshould be dictionary with simple objects:NSStringandNSNumber. remove#- List of
channelsfrom whichUUIDshould be removed asmember. includeFields#- Bitfield set to fields which should be returned with response. Supported fields:
PNMembershipsTotalCountField- include how many membershipsUUIDhas.PNMembershipCustomField- include field with additional information frommetadatawhich has been associated withUUIDduringmembership setrequests.PNMembershipStatusField- include field withmetadatastatus which has been associated withUUIDduringmembership setrequests.PNMembershipTypeField- include field withmetadatatype which has been associated withUUIDduringmembership setrequests.PNMembershipChannelField- includechannel's metadatainto response (not only name).PNMembershipChannelCustomField- includechannel'sadditional information which has been used duringchannel metadata setrequests.PNMembershipChannelStatusField- includechannel'sstatuswhich has been used duringchannel metadata setrequests.PNMembershipChannelTypeField- includechannel'stypewhich has been used duringchannel metadata setrequests.
includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Manage UUID's membershipsrequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1NSArray<NSDictionary *> *setChannels = @[
2 @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
3];
4NSArray<NSString *> *removeChannels = @[@"channel3", @"channel4"];
5
6self.client.objects().manageMemberships()
7 .uuid(@"uuid")
8 .set(setChannels)
9 .remove(removeChannels)
10 .includeCount(YES)
11 .limit(40)
12 .includeFields(PNMembershipCustomField | PNMembershipChannelField)
13 .performWithCompletion(^(PNManageMembershipsStatus *status) {
14 if (!status.isError) {
15 /**
show all 31 linesResponse
Response returned by the client for manage memberships:
1@interface PNManageMembershipsData : PNServiceData
2
3// List of existing memberships.
4@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
show all 28 linesChannel members
Get channel members
The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.
Method(s)
To Get Channel Members you can use the following method(s) in the Objective-C SDK:
1- (void)channelMembersWithRequest:(PNFetchChannelMembersRequest *)request
2 completion:(PNFetchChannelMembersCompletionBlock)block;
PNFetchChannelMembersRequest
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1PNFetchChannelMembersRequest *request = [PNFetchChannelMembersRequest requestWithChannel:@"channel"];
2request.start = @"<next from previous request>";
3// Add this request option, if returned member models should have value which has been set to
4// 'custom' and 'uuid' properties.
5request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
6request.limit = 40;
7
8[self.client channelMembersWithRequest:request
9 completion:^(PNFetchChannelMembersResult *result, PNErrorStatus *status) {
10
11 if (!status.isError) {
12 /**
13 * Channel's members successfully fetched.
14 * Result object has following information:
15 * result.data.members - List of channel's members.
show all 28 linesResponse
Response returned by the client for fetch members:
1@interface PNFetchChannelMembersData : PNServiceData
2
3// List of fetched members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of members created for current subscribe key.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesGet channel members (builder pattern)
Method(s)
1objects()
2 .channelMembers(NSString *)
3 .includeFields(PNChannelMemberFields)
4 .includeCount(BOOL)
5 .filter(NSString *)
6 .sort(NSArray<NSString *> *)
7 .limit(NSUInteger)
8 .start(NSString *)
9 .end(NSString *)
10 .performWithCompletion(PNFetchChannelMembersCompletionBlock);
channelrequired#- Name of channel from which members should be fetched.
includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. includeCount#- Whether to include the total count in the paginated response. Default:
YES filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. blockrequired#Fetch channel's membersrequest completion block.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().channelMembers(@"channel")
2 .includeCount(YES)
3 .limit(40)
4 .includeFields(PNChannelMemberCustomField | PNChannelMemberUUIDField)
5 .performWithCompletion(^(PNFetchChannelMembersResult *result, PNErrorStatus *status) {
6 if (!status.isError) {
7 /**
8 * Channel's members successfully fetched.
9 * Result object has following information:
10 * result.data.members - List of channel's members.
11 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
12 * result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
13 * result.data.totalCount - Total number of channel's members.
14 */
15 } else {
show all 23 linesResponse
Response returned by the client for fetch members:
1@interface PNFetchChannelMembersData : PNServiceData
2
3// List of fetched members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of members created for current subscribe key.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesError response which is used in case of App Context API call failure:
1@interface PNErrorData : PNServiceData
2
3// Stringified error information.
4@property (nonatomic, readonly, strong) NSString *information;
5
6@end
7
8@interface PNErrorStatus : PNStatus
9
10// Whether status object represent error or not.
11@property (nonatomic, readonly, assign, getter = isError) BOOL error;
12
13// Additional information related to error status object.
14@property (nonatomic, readonly, strong) PNErrorData *errorData;
15
show all 16 linesSet channel members
This method sets members in a channel.
Method(s)
To Set Channel Members you can use the following method(s) in the Objective-C SDK:
1- (void)setChannelMembersWithRequest:(PNSetChannelMembersRequest *)request
2 completion:(nullable PNManageChannelMembersCompletionBlock)block;
PNSetMembersRequest
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
API limits
To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.
Sample code
1NSArray<NSDictionary *> *uuids = @[
2 @{
3 @"uuid": @"uuid2"
4 @"status": @"active",
5 @"type": @"admin",
6 @"custom": @{ @"role": @"moderator" }
7 }
8];
9
10PNSetChannelMembersRequest *request = [PNSetChannelMembersRequest requestWithChannel:@"channel" uuids:uuids];
11// Add this request option, if returned member models should have value which has been set to
12// 'custom' and 'uuid' properties.
13request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
14request.limit = 40;
15
show all 34 linesResponse
Response returned by the client for set members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesSet channel members (builder pattern)
Method(s)
1objects()
2 .setChannelMembers(NSString *)
3 .uuids(NSArray<NSDictionary *> *)
4 .includeFields(PNChannelMemberFields)
5 .includeCount(BOOL)
6 .filter(NSString *)
7 .sort(NSArray<NSString *> *)
8 .limit(NSUInteger)
9 .start(NSString *)
10 .end(NSString *)
11 .performWithCompletion(nullable PNManageChannelMembersCompletionBlock);
API limits
To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs.
channelrequired#- Name of channel from which members should be set.
uuids#- List of
UUIDsfor whichmetadataassociated with each of them in context ofchannelshould be set. Each entry is dictionary withUUIDandoptionalcustomfields.customshould be dictionary with simple objects:NSStringandNSNumber. includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. includeCount#- Whether to include the total count in the paginated response. Default:
YES sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Set channel's memberslist request completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1NSArray<NSDictionary *> *uuids = @[
2 @{
3 @"uuid": @"uuid2"
4 @"status": @"active",
5 @"type": @"admin",
6 @"custom": @{ @"role": @"moderator" }
7 }
8];
9
10self.client.objects().setChannelMembers(@"channel")
11 .uuids(uuids)
12 .includeCount(YES)
13 .limit(40)
14 .includeFields(PNChannelMemberCustomField | PNChannelMemberUserField)
15 .performWithCompletion(^(PNManageChannelMembersStatus *status) {
show all 33 linesResponse
Response returned by the client for set members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesRemove channel members
Remove members from a Channel.
Method(s)
To Remove Channel Members you can use the following method(s) in the Objective-C SDK:
1- (void)removeChannelMembersWithRequest:(PNRemoveChannelMembersRequest *)request
2 completion:(nullable PNManageChannelMembersCompletionBlock)block;
PNRemoveChannelMembersRequest
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1NSArray<NSString *> *uuids = @[@"uuid3", @"uuid4"];
2PNRemoveChannelMembersRequest *request = [PNRemoveChannelMembersRequest requestWithChannel:@"channel"
3 uuids:uuids];
4// Add this request option, if returned member models should have value which has been set to
5// 'custom' and 'uuid' properties.
6request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
7request.limit = 40;
8
9[self.client removeChannelMembersWithRequest:request completion:^(PNManageChannelMembersStatus *status) {
10 if (!status.isError) {
11 /**
12 * Channel's members successfully removed.
13 * Result object has following information:
14 * result.data.members - List of channel's existing members.
15 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
show all 27 linesResponse
Response returned by the client for remove members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesRemove channel members (builder pattern)
Method(s)
1objects()
2 .removeChannelMembers(NSString *)
3 .uuids(NSArray<NSString *> *)
4 .includeFields(PNChannelMemberFields)
5 .includeCount(BOOL)
6 .filter(NSString *)
7 .sort(NSArray<NSString *> *)
8 .limit(NSUInteger)
9 .start(NSString *)
10 .end(NSString *)
11 .performWithCompletion(nullable PNManageChannelMembersCompletionBlock);
channelrequired#- Name of channel from which members should be removed.
uuids#- List of
UUIDswhich should be removed fromchannel'slist. includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. includeCount#- Whether to include the total count in the paginated response. Default:
YES filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Remove channel's membersrequest completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1self.client.objects().removeChannelMembers(@"channel")
2 .uuids(@[@"uuid3", @"uuid4"])
3 .includeCount(YES)
4 .limit(40)
5 .includeFields(PNChannelMemberCustomField | PNChannelMemberUserField)
6 .performWithCompletion(^(PNManageChannelMembersStatus *status) {
7 if (!status.isError) {
8 /**
9 * Channel's members successfully removed.
10 * Result object has following information:
11 * result.data.members - List of channel's existing members.
12 * result.data.next - Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
13 * result.data.prev - Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
14 * result.data.totalCount - Total number of channel's members.
15 */
show all 24 linesResponse
Response returned by the client for remove members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesManage channel members
The method Set and Remove channel memberships for a user.
Method(s)
To Manage Channel Members you can use the following method(s) in the Objective-C SDK:
1- (void)manageChannelMembersWithRequest:(PNManageChannelMembersRequest *)request
2 completion:(nullable PNManageChannelMembersCompletionBlock)block;
PNManageChannelMembersRequest
setMembers#- List of UUIDs which should be added to channel's members list. Each entry is dictionary with uuid and optional
customfields.customshould be dictionary with simple objects: NSString and NSNumber. removeMembers#- BList of UUIDs which should be removed from channel's list.
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. limit#- Number of objects to return. Default/Max: 100.
Sample code
1PNManageChannelMembersRequest *request = [PNManageChannelMembersRequest requestWithChannel:@"channel"];
2request.setMembers = @[
3 @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
4];
5request.removeMembers = @[@"uuid3", @"uuid4"];
6// Add this request option, if returned member models should have value which has been set to
7// 'custom' and 'uuid' properties.
8request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
9request.limit = 40;
10
11[self.client manageChannelMembersWithRequest:request
12 completion:^(PNManageChannelMembersStatus *status) {
13
14 if (!status.isError) {
15 /**
show all 31 linesResponse
Response returned by the client for manage members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 linesManage channel members (builder pattern)
Method(s)
1objects()
2 .manageChannelMembers(NSString *)
3 .set(NSArray<NSDictionary *> *)
4 .remove(NSArray<NSString *> *)
5 .includeFields(PNChannelMemberFields)
6 .includeCount(BOOL)
7 .filter(NSString *)
8 .sort(NSArray<NSString *> *)
9 .limit(NSUInteger)
10 .start(NSString *)
11 .end(NSString *)
12 .performWithCompletion(nullable PNManageChannelMembersCompletionBlock);
channelrequired#- Name of channel from which members should be managed.
set#- List of
UUIDswhich should be added tochannel'smembers list. Each entry is dictionary withUUIDandoptionalcustomfields.customshould be dictionary with simple objects:NSStringandNSNumber. remove#- List of
UUIDswhich should be removed fromchannel'slist. includeFields#- Bitfield set to fields that should be returned with the response. Supported fields:
PNChannelMembersTotalCountField- include how many members the channel has.PNChannelMemberCustomField- include field with additional information frommetadataassociated withUUIDduringchannel member setrequests.PNChannelMemberStatusField- include field withmetadatastatus associated withUUIDduringchannel member setrequests.PNChannelMemberTypeField- include field withmetadatatype associated withUUIDduringchannel member setrequests.PNChannelMemberUUIDField- includeUUID'smetadatain the response (not only the identifier).PNChannelMemberUUIDCustomField- includeUUID's additional information used duringUUID metadata setrequests.PNChannelMemberUUIDStatusField- includeUUID'sstatusused duringUUID metadata setrequests.PNChannelMemberUUIDTypeField- includeUUID'stypeused duringUUID metadata setrequests.
PNChannelMembersTotalCountField) can be reset by setting it to 0. includeCount#- Whether to include the total count in the paginated response. Default is false.
filter#- Expression to filter out results basing on specified criteria. For more details on the supported grammar, check this
sort#- List of criteria (name of field) which should be used for sorting in ascending order. Available options are
id,name, andupdated. Useascordescto specify sort direction. For example:{name: 'asc'} limit#- Number of objects to return. Default/Max: 100.
start#- Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
end#- Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the
startparameter is supplied. block#Set channel's memberslist request completionblock.
Note
This method uses the builder pattern, you can remove the arguments which are optional.
Sample code
1NSArray<NSDictionary *> *setMembers = @[
2 @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
3];
4NSArray<NSDictionary *> *removeMembers = @[@"uuid3", @"uuid4"];
5
6self.client.objects().manageChannelMembers(@"channel")
7 .set(setMembers)
8 .remove(removeMembers)
9 .includeCount(YES)
10 .limit(40)
11 .includeFields(PNChannelMemberCustomField | PNChannelMemberUUIDField)
12 .performWithCompletion(^(PNManageChannelMembersStatus *status) {
13 if (!status.isError) {
14 /**
15 * Channel's members successfully changed.
show all 30 linesResponse
Response returned by the client for manage members:
1@interface PNManageChannelMembersData : PNServiceData
2
3// List of existing members.
4@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;
5
6// Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
7@property (nonatomic, nullable, readonly, strong) NSString *next;
8
9// Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data.
10@property (nonatomic, nullable, readonly, strong) NSString *prev;
11
12/**
13 * Total number of existing objects.
14 *
15 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
show all 28 lines