Objective-CCocoaCocoaiOSCocoa Objects API Reference for Realtime Apps

This page describes the new Objects v2. To upgrade from Objects v1, refer to the migration guide.

Objects provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use Objects to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is set or removed from the database. Clients can receive these events in realtime and update their front-end application accordingly.

Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each.

To Get All UUID Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchAllUUIDMetadataRequestYesFetch all UUID metadata request object with all information which should be used to fetch existing UUID metadata.
    blockPNFetchAllUUIDMetadataCompletionBlockYesFetch all UUID metadata request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, Use asc or desc to specify sort direction
    includeFieldsPNUUIDFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNUUIDTotalCountField - include how many UUID has been associated with metadata.
    • PNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.

    Default value (PNUUIDTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNFetchAllUUIDMetadataRequest *request = [PNFetchAllUUIDMetadataRequest new];
request.start = @"<next from previous request>";
// Add this request option, if returned metadata models should have value which has been set to
// 'custom' property.
request.includeFields = PNUUIDCustomField | PNUUIDTotalCountField;
request.limit = 40;

[self.client allUUIDMetadataWithRequest:request
                             completion:^(PNFetchAllUUIDMetadataResult *result, PNErrorStatus *status) {

    if (!status.isError) {
        /**
         * UUID metadata successfully fetched.
         * Result object has following information:
         *   result.data.metadata - list of fetched UUID metadata,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of created UUID metadata.
         */
    } else {
        /**
         * Handle UUID metadata fetch error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch all UUID metadata Object API is used:

@interface PNFetchAllUUIDMetadataData : PNServiceData

// List of UUID metadata objects created for current subscribe key.
@property (nonatomic, readonly, strong) NSArray<PNUUIDMetadata *> *metadata;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of objects created for current subscribe key.
 *
 * Value will be 0 in case if PNUUIDTotalCountField not added to 'includeFields'
 * of PNFetchAllUUIDMetadataRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchAllUUIDMetadataResult : PNResult

// Fetch all UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchAllUUIDMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    includeFieldsPNUUIDFieldsNoPNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNFetchAllUUIDMetadataCompletionBlockYesAssociated metadata fetch completion handler block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().allUUIDMetadata()
    .start(@"<next from previous request>")
    .includeFields(PNUUIDCustomField)
    .includeCount(YES)
    .limit(40)
    .performWithCompletion(^(PNFetchAllUUIDMetadataResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * UUID metadata successfully fetched.
             * Result object has following information:
             *   result.data.metadata - list of fetched UUID metadata,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of created UUID metadata.
             */
        } else {
            /**
             * Handle UUID metadata fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when fetch all UUID metadata Object API is used:

@interface PNFetchAllUUIDMetadataData : PNServiceData

// List of UUID metadata objects created for current subscribe key.
@property (nonatomic, readonly, strong) NSArray<PNUUIDMetadata *> *metadata;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of objects created for current subscribe key.
 *
 * Value will be 0 in case if PNUUIDTotalCountField not added to 'includeFields'
 * of PNFetchAllUUIDMetadataRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchAllUUIDMetadataResult : PNResult

// Fetch all UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchAllUUIDMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Returns metadata for the specified UUID, optionally including the custom data object for each.

To Get UUID Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchUUIDMetadataRequestYesFetch UUID metadata request with all information which should be used to fetch existing UUID metadata.
    blockPNFetchUUIDMetadataCompletionBlockYesFetch UUID metadata request completion block.
  1. ParameterTypeRequiredDescription
    includeFieldsPNUUIDFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.
    Default value (PNUUIDCustomField) can be reset by setting 0.
    uuidNSStringNoCreate and configure fetch UUID metadata request.
    uuid - Identifier for metadata should be fetched.
    Will be set to current PubNub configuration uuid if nil is set.
PNFetchUUIDMetadataRequest *request = [PNFetchUUIDMetadataRequest requestWithUUID:@"uuid"];
// Add this request option, if returned metadata model should have value which has been set to
// 'custom' property.
request.includeFields = PNUUIDCustomField;

[self.client uuidMetadataWithRequest:request
                          completion:^(PNFetchUUIDMetadataResult *result, PNErrorStatus *status) {

    if (!status.isError) {
        /**
         * UUID metadata successfully fetched.
         * Fetched UUID metadata information available here: result.data.metadata
         */
    } else {
        /**
         * Handle UUID metadata fetch error. Check 'category' property to find out possible issue
         * because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch UUID metadata Object API is used:

@interface PNFetchUUIDMetadataData : PNServiceData

// Requested UUID metadata object.
@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;

@end
 
 
@interface PNFetchUUIDMetadataResult : PNResult

// Fetch UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchUUIDMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier for which associated metadata should be fetched.
    Default: configured PubNub client uuid
    includeFieldsPNUUIDMFieldsNoPNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.
    Default: PNUUIDCustomField

    Default value can be reset by setting 0
    blockPNFetchUUIDMetadataCompletionBlockYesFetch UUID metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().uuidMetadata()
    .uuid(@"uuid")
    .includeFields(PNUUIDCustomField)
    .performWithCompletion(^(PNFetchUUIDMetadataResult *result, PNErrorStatus *status) {
      if (!status.isError) {
          /**
           * UUID metadata successfully fetched.
           * Fetched UUID metadata information available here: result.data.metadata
           */
      } else {
          /**
           * Handle UUID metadata fetch error. Check 'category' property to find out possible issue
           * because of which request did fail.
           *
           * Request can be resent using: [status retry]
           */
      }
    });

Response objects which is returned by client when fetch UUID metadata Object API is used:

@interface PNFetchUUIDMetadataData : PNServiceData

// Requested UUID metadata object.
@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;

@end
 
 
@interface PNFetchUUIDMetadataResult : PNResult

// Fetch UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchUUIDMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Set metadata for a UUID in the database, optionally including the custom data object for each.

To Set UUID Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNSetUUIDMetadataRequestYesSet UUID metadata request with all information which should be associated with UUID.
    blockPNSetUUIDMetadataCompletionBlockNoSet UUID metadata request completion block.
  1. ParameterTypeRequiredDescription
    customNSDictionaryNoAdditional / complex attributes which should be associated with metadata.
    externalIdNSStringNoIdentifier from external service (database, auth service).
    profileUrlNSStringNoURL at which profile available.
    includeFieldsPNUUIDFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.
    Default value (PNUUIDCustomField) can be reset by setting 0.
    emailNSStringNoEmail address.
    nameNSStringNoName which should be stored in metadata associated with specified identifier.
    uuidNSStringNoCreate 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.
PNSetUUIDMetadataRequest *request = [PNSetUUIDMetadataRequest requestWithUUID:@"uuid"];
// With this option on, returned metadata model will have value which has been set to 'custom'
// property.
request.includeFields = PNUUIDCustomField;
request.custom = @{ @"age": @(39), @"status": @"Checking some stuff..." };
request.email = @"support@pubnub.com";
request.name = @"David";

[self.client setUUIDMetadataWithRequest:request completion:^(PNSetUUIDMetadataStatus *status) {
    if (!status.isError) {
        /**
         * UUID metadata successfully has been set.
         * UUID metadata information available here: status.data.metadata
         */
    } else {
        /**
         * Handle UUID metadata set error. Check 'category' property to find out possible issue
         * because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when set UUID metadata Object API is used:

@interface PNSetUUIDMetadataData : PNServiceData

// Updated UUID metadata object.
@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;

@end
 
 
@interface PNSetUUIDMetadataStatus : PNAcknowledgmentStatus

// Set UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNSetUUIDMetadataData *data;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier with which new metadata should be associated.
    Default: configured PubNub client uuid
    nameNSStringNoName which should stored in metadata associated with specified UUID.
    externalIdNSStringNoExternal identifier (database, auth service) associated with specified UUID.
    profileUrlNSStringNoExternal URL with information for specified UUID representation.
    customNSDictionaryNoAdditional information which should be stored in metadata associated with specified UUID.
    emailNSStringNoEmail address which should be stored in metadata associated with specified UUID.
    includeFieldsPNUUIDFieldsNoPNUUIDCustomField - include field with additional information from metadata which has been used during UUID metadata set requests.
    Default: PNUUIDCustomField

    Default value can be reset by setting 0.
    blockPNSetUUIDMetadataCompletionBlockNoSet UUID metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().setUUIDMetadata()
    .uuid(@"uuid")
    .name(@"Serhii")
    .externalId(@"93FVfHUAf4RLu79J7Q3ejLVu")
    .profileUrl(@"https://pubnub.com")
    .custom(@{ @"age": @(36) })
    .email(@"support@pubnub.com")
    .includeFields(PNUUIDCustomField)
    .performWithCompletion(^(PNSetUUIDMetadataStatus *status) {
        if (!status.isError) {
            /**
             * UUID metadata successfully has been set.
             * UUID metadata information available here: status.data.metadata
             */
        } else {
            /**
             * Handle UUID metadata set error. Check 'category' property to find out possible issue
             * because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when set UUID metadata Object API is used:

@interface PNSetUUIDMetadataData : PNServiceData

// Updated UUID metadata object.
@property (nonatomic, nullable, readonly, strong) PNUUIDMetadata *metadata;

@end
 
 
@interface PNSetUUIDMetadataStatus : PNAcknowledgmentStatus

// Set UUID metadata request processed information.
@property (nonatomic, readonly, strong) PNSetUUIDMetadataData *data;

@end

Removes the metadata from a specified UUID.

To Remove UUID Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNRemoveUUIDMetadataRequestYesRemove UUID metadata request with information about existing metadata.
    blockPNRemoveUUIDMetadataCompletionBlockNoRemove UUID metadata request completion block.
  1. ParameterTypeRequiredDescription
    uuidNSStringNoCreate and configure delete user request.
    identifier - Create and configure remove UUID metadata request.
    Will be set to current PubNub configuration uuid if nil is set.
PNRemoveUUIDMetadataRequest *request = [PNRemoveUUIDMetadataRequest requestWithUUID:@"uuid"];

[self.client removeUUIDMetadataWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        // UUID metadata successfully removed.
    } else {
        /**
         * Handle UUID metadata remove error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when remove UUID metadata Object API is used:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier for which associated metadata should be removed.
    Default: configured PubNub client uuid
    blockPNRemoveUUIDMetadataCompletionBlockNoRemove UUID metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().removeUUIDMetadata()
    .uuid(@"uuid")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
             // User successfully deleted.
        } else {
            /**
             * Handle user delete error. Check 'category' property to find out possible issue
             * because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when remove UUID metadata Object API is used:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

To Get All Channel Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchAllChannelsMetadataRequestYesFetch all UUID metadata request object with all information which should be used to fetch existing UUID metadata.
    blockPNFetchAllChannelsMetadataCompletionBlockYesFetch all UUID metadata request completion block.
  1. ParameterTypeRequiredDescription
    includeFieldsPNChannelFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNChannelTotalCountField - include how many channels has been associated with metadata.
    • PNChannelCustomField - include field with additional information from metadata which has been used during channel metadata set requests.
    Default value (PNChannelTotalCountField) can be reset by setting 0.
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNFetchAllChannelsMetadataRequest *request = [PNFetchAllChannelsMetadataRequest new];
request.start = @"<next from previous request>";
// Add this request option, if returned metadata models should have value which has been set to
// 'custom' property.
request.includeFields = PNUUIDCustomField | PNUUIDTotalCountField;
request.limit = 40;

[self.client allChannelsMetadataWithRequest:request
                                 completion:^(PNFetchAllChannelsMetadataResult *result, PNErrorStatus *status) {
    if (!status.isError) {
        /**
         * Channels metadata successfully fetched.
         * Result object has following information:
         *   result.data.metadata - list of fetched channels metadata,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of associated channel metadata.
    } else {
        /**
         * Handle channels metadata fetch error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch all UUID metadata Object API is used:

@interface PNFetchAllChannelsMetadataData : PNServiceData

// List of channels metadata objects created for current subscribe key.
@property (nonatomic, readonly, strong) NSArray<PNChannelMetadata *> *metadata;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of objects created for current subscribe key.
 *
 * Value will be 0 in case if PNChannelTotalCountField not added to 'includeFields'
 * of PNFetchAllChannelsMetadataRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchAllChannelsMetadataResult : PNResult

// Fetch all channels metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchAllChannelsMetadataData *data;

@end

Error response which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    includeFieldsPNChannelFieldsNoPNChannelCustomField - include field with additional information from metadata which has been used during channel metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNFetchAllChannelsMetadataCompletionBlockYesFetch all UUID metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().allChannelsMetadata()
    .start(@"<next from previous request>")
    .includeFields(PNChannelCustomField)
    .includeCount(YES)
    .limit(40)
    .performWithCompletion(^(PNFetchAllChannelsMetadataResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * Channels metadata successfully fetched.
             * Result object has following information:
             *   result.data.metadata - list of fetched channels metadata,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of associated channel metadata.
        } else {
            /**
             * Handle channels metadata fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when fetch all UUID metadata Object API is used:

@interface PNFetchAllChannelsMetadataData : PNServiceData

// List of channels metadata objects created for current subscribe key.
@property (nonatomic, readonly, strong) NSArray<PNChannelMetadata *> *metadata;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of objects created for current subscribe key.
 *
 * Value will be 0 in case if PNChannelTotalCountField not added to 'includeFields'
 * of PNFetchAllChannelsMetadataRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchAllChannelsMetadataResult : PNResult

// Fetch all channels metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchAllChannelsMetadataData *data;

@end

Error response which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Returns metadata for the specified Channel, optionally including the custom data object for each.

To Get Channel Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchChannelMetadataRequestYesFetch channel metadata request with all information which should be used to fetch existing channel metadata.
    blockPNFetchChannelMetadataCompletionBlockYesFetch channel metadata request completion block.
  1. ParameterTypeRequiredDescription
    includeFieldsPNChannelFieldsNoBitfield 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.
    Default value (PNChannelCustomField) can be reset by setting 0.
    channelNSStringNoCreate and configure fetch channel metadata request.
    channel - Name of channel for which metadata should be fetched.
PNFetchChannelMetadataRequest *request = [PNFetchChannelMetadataRequest requestWithChannel:@"channel"];
// Add this request option, if returned metadata model should have value which has been set to
// 'custom' property.
request.includeFields = PNChannelCustomField;

[self.client channelMetadataWithRequest:request
                             completion:^(PNFetchChannelsMetadataResult *result, PNErrorStatus *status) {

    if (!status.isError) {
        /**
         * Channel metadata successfully fetched.
         * Channel metadata information available here: result.data.metadata
         */
    } else {
        /**
         * Handle channel metadata fetch error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch channel metadata Object API is used:

@interface PNFetchChannelMetadataData : PNServiceData

// Requested channel metadata object.
@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;

@end
 
 
@interface PNFetchChannelsMetadataResult : PNResult

// Fetch channel metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchChannelMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel for which associated metadata should be fetched.
    includeFieldsNSStringNoPNChannelCustomField - include field with additional information from metadata which has been used during channel metadata set requests.

    Default: PNChannelCustomField
    Default value can be reset by setting 0
    blockPNFetchChannelMetadataCompletionBlockYesFetch channel metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().channelMetadata(@"channel")
    .includeFields(PNChannelCustomField)
    .performWithCompletion(^(PNFetchChannelsMetadataResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * Channel metadata successfully fetched.
             * Channel metadata information available here: result.data.metadata
             */
        } else {
            /**
             * Handle channel metadata fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when fetch channel metadata Object API is used:

@interface PNFetchChannelMetadataData : PNServiceData

// Requested channel metadata object.
@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;

@end
 
 
@interface PNFetchChannelsMetadataResult : PNResult

// Fetch channel metadata request processed information.
@property (nonatomic, readonly, strong) PNFetchChannelMetadataData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Set metadata for a Channel in the database, optionally including the custom data object for each.

To Set Channel Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNSetChannelMetadataRequestYesSet channel metadata request with all information which should be associated with channel.
    blockPNSetChannelMetadataCompletionBlockNoSet channel metadata request completion block.
  1. ParameterTypeRequiredDescription
    customNSDictionaryNoAdditional / complex attributes which should be stored in metadata associated with specified channel.
    informationNSStringNoDescription which should be stored in metadata associated with specified channel.
    includeFieldsPNChannelFieldsNoBitfield 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.
    Default value (PNChannelCustomField) can be reset by setting 0.
    nameNSStringNoName which should be stored in metadata associated with specified channel.
    channelNSStringNoCreate and configure set channel metadata request.
    channel - Name of channel for which metadata should be set.
PNSetChannelMetadataRequest *request = [PNSetChannelMetadataRequest requestWithChannel:@"channel"];
// Add this request option, if returned metadata model should have value which has been set to
// 'custom' property.
request.includeFields = PNChannelCustomField;
request.custom = @{ @"responsibilities": @"Manage tests", @"status": @"offline" };
request.name = @"Updated channel name";

[self.client setChannelMetadataWithRequest:request completion:^(PNSetChannelMetadataStatus *status) {
    if (!status.isError) {
        /**
         * Channel metadata successfully has been set.
         * Channel metadata information available here: status.data.metadata
         */
    } else {
        /**
         * Handle channel metadata update error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when set channel metadata Object API is used:

@interface PNSetChannelMetadataData : PNServiceData

// Associated channel's metadata object.
@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;

@end
 
 
@interface PNSetChannelMetadataStatus : PNAcknowledgmentStatus

// Set channel metadata request processed information.
@property (nonatomic, readonly, strong) PNSetChannelMetadataData *data;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel with which new metadata should be associated.
    nameNSStringNoName which should stored in metadata associated with specified channel.
    informationNSStringNoDescription which should be stored in metadata associated with specified channel.
    customNSDictionaryNoAdditional information which should be stored in metadata associated with specified channel.
    includeFieldsPNChannelFieldsNoPNChannelCustomField - include field with additional information from metadata which has been used during channel metadata set requests.

    Default: PNChannelCustomField
    Default value can be reset by setting 0.
    blockPNSetChannelMetadataCompletionBlockNoSet channel metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().setChannelMetadata(@"channel")
    .name(@"Admin")
    .information(@"Administrative channel")
    .custom(@{ @"responsibilities": @"Manage access to protected resources" })
    .includeFields(PNChannelCustomField)
    .performWithCompletion(^(PNSetChannelMetadataStatus *status) {
      if (!status.isError) {
          /**
           * Channel metadata successfully has been set.
           * Channel metadata information available here: status.data.metadata
           */
      } else {
          /**
           * Handle channel metadata update error. Check 'category' property to find out possible
           * issue because of which request did fail.
           *
           * Request can be resent using: [status retry]
           */
      }
    });

Response objects which is returned by client when set channel metadata Object API is used:

@interface PNSetChannelMetadataData : PNServiceData

// Associated channel's metadata object.
@property (nonatomic, nullable, readonly, strong) PNChannelMetadata *metadata;

@end
 
 
@interface PNSetChannelMetadataStatus : PNAcknowledgmentStatus

// Set channel metadata request processed information.
@property (nonatomic, readonly, strong) PNSetChannelMetadataData *data;

@end

Removes the metadata from a specified channel.

To Remove Channel Metadata you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNRemoveChannelMetadataRequestYesRemove channel metadata request with information about existing metadata.
    blockPNRemoveChannelMetadataCompletionBlockNoRemove channel metadata request completion block.
  1. ParameterTypeRequiredDescription
    channelNSStringNoCreate and configure remove channel metadata request.
    channel - Name of channel for which metadata should be removed.
PNRemoveChannelMetadataRequest *request = [PNRemoveChannelMetadataRequest requestWithChannel:@"channel"];

[self.client removeChannelMetadataWithRequest:request completion:^(PNAcknowledgmentStatus *status) {
    if (!status.isError) {
        // Channel metadata successfully removed.
    } else {
        /**
         * Handle channel metadata remove error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when remove channel metadata Object API is used:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

 
@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel for which associated metadata should be removed.
    blockPNRemoveChannelMetadataCompletionBlockNoRemove channel metadata request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().removeChannelMetadata(@"channel")
    .performWithCompletion(^(PNAcknowledgmentStatus *status) {
        if (!status.isError) {
            // Channel metadata successfully removed.
        } else {
            /**
             * Handle channel metadata remove error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when remove channel metadata Object API is used:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end

 
@interface PNAcknowledgmentStatus : PNErrorStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.

To Get Memberships you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchMembershipsRequestYesFetch UUID's memberships request with all information which should be used to fetch existing UUID's memberships.
    blockPNFetchMembershipsCompletionBlockYesFetch UUID's memberships request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsNSArray<NSString *>NoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNMembershipsTotalCountField - include how many memberships UUID has.
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership add requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    Default value (PNMembershipsTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of members to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNFetchMembershipsRequest *request = [PNFetchMembershipsRequest requestWithUUID:@"uuid"];
request.start = @"<next from previous request>";
// Add this request option, if returned membership models should have value which has been set to
// 'custom' and 'channel' properties.
request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
request.limit = 40;

[self.client membershipsWithRequest:request
                         completion:^(PNFetchMembershipsResult *result, PNErrorStatus *status) {

    if (!status.isError) {
        /**
         * UUID's memberships successfully fetched.
         * Result object has following information:
         *   result.data.memberships - list of UUID's memberships,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of UUID's memberships
         */
    } else {
        /**
         * Handle UUID's memberships fetch error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch memberships Object API is used:

@interface PNFetchMembershipsData : PNServiceData

// List of fetched memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of members created for current subscribe key.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchMembershipsResult : PNAcknowledgmentStatus

// Fetch memberships request processed information.
@property (nonatomic, readonly, strong) PNFetchMembershipsData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoName of channel from which members should be fetched.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership set requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNFetchMembershipsCompletionBlockYesFetch UUID's memberships request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().memberships()
    .uuid(@"uuid")
    .includeCount(YES)
    .limit(40)
    .includeFields(PNMembershipCustomField | PNMembershipChannelField)
    .performWithCompletion(^(PNFetchMembershipsResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * UUID's memberships successfully fetched.
             * Result object has following information:
             *   result.data.memberships - list of UUID's memberships,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of UUID's memberships
             */
        } else {
            /**
             * Handle UUID's memberships fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when fetch memberships Object API is used:

@interface PNFetchMembershipsData : PNServiceData

// List of fetched memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of members created for current subscribe key.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchMembershipsResult : PNAcknowledgmentStatus

// Fetch memberships request processed information.
@property (nonatomic, readonly, strong) PNFetchMembershipsData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

Set channel memberships for a UUID.

To Set Memberships you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNSetMembershipsRequestYesSet UUID's memberships request with information which should be used to set channels membership.
    blockPNManageMembershipsCompletionBlockNoSet UUID's memberships request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsPNMembershipFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNMembershipsTotalCountField - include how many memberships UUID has.
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership add requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    Default value (PNMembershipsTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
NSArray<NSDictionary *> *channels = @[
  @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
];

PNSetMembershipsRequest *request = [PNSetMembershipsRequest requestWithUUID:@"uuid"
                                                                   channels:channels];
// Add this request option, if returned membership models should have value which has been set to
// 'custom' and 'channel' properties.
request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
request.limit = 40;

[self.client setMembershipsWithRequest:request completion:^(PNManageMembershipsStatus *status) {
    if (!status.isError) {
        /**
         * UUID's memberships successfully set.
         * Result object has following information:
         *   status.data.memberships - list of UUID's existing memberships,
         *   status.data.next - cursor bookmark for fetching the next page,
         *   status.data.prev - cursor bookmark for fetching the previous page,
         *   status.data.totalCount - total number of UUID's memberships.
         */
    } else {
        /**
         * Handle UUID's memberships set error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when set memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier for which memberships should be set.
    Default: configured PubNub client uuid
    channelsNSArrayNoList of channels for which metadata associated with each of them in context of UUID should be set.

    Each entry is dictionary with channel and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership set requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageMembershipsCompletionBlockNoSet UUID's memberships request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
NSArray<NSDictionary *> *channels = @[
  @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
];

self.client.objects().setMemberships()
    .uuid(@"uuid")
    .channels(channels)
    .includeCount(YES)
    .limit(40)
    .includeFields(NMembershipCustomField | PNMembershipChannelField)
    .performWithCompletion(^(PNManageMembershipsStatus *status) {
        if (!status.isError) {
            /**
             * UUID's memberships successfully set.
             * Result object has following information:
             *   status.data.memberships - list of UUID's existing memberships,
             *   status.data.next - cursor bookmark for fetching the next page,
             *   status.data.prev - cursor bookmark for fetching the previous page,
             *   status.data.totalCount - total number of UUID's memberships.
             */
        } else {
            /**
             * Handle UUID's memberships set error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when set memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end

Remove channel memberships for a UUID.

To Remove Memberships you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNRemoveMembershipsRequestYesRemove UUID's memberships request with information which should be used to remove channels membership.
    blockPNManageMembershipsCompletionBlockNoRemove UUID's memberships request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsPNMembershipFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNMembershipsTotalCountField - include how many memberships UUID has.
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership add requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    Default value (PNMembershipsTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
NSArray<NSString *> *channels = @[@"channel1", @"channel2"];
PNRemoveMembershipsRequest *request = [PNRemoveMembershipsRequest requestWithUUID:@"uuid"
                                                                         channels:channels];
// Add this request option, if returned membership models should have value which has been set to
// 'custom' and 'channel' properties.
request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
request.limit = 40;

[self.client removeMembershipsWithRequest:request
                               completion:^(PNManageMembershipsStatus *status) {

    if (!status.isError) {
        /**
         * UUID's memberships successfully removed.
         * Result object has following information:
         *   status.data.memberships - list of UUID's existing memberships,
         *   status.data.next - cursor bookmark for fetching the next page,
         *   status.data.prev - cursor bookmark for fetching the previous page,
         *   status.data.totalCount - total number of UUID's memberships.
         */
    } else {
        /**
         * Handle UUID's memberships remove error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when remove memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier for which memberships should be removed.
    Default: configured PubNub client uuid
    channelsNSArrayNoList of channels from which UUID should be removed as member.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership set requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    includeCountBOOLNoWhether total count of members should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageMembershipsCompletionBlockNoRemove UUID's memberships request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().removeMemberships()
    .uuid(@"uuid")
    .channels(@[@"channel1", @"channel2"])
    .includeCount(YES)
    .limit(40)
    .includeFields(PNMembershipCustomField | PNMembershipChannelField)
    .performWithCompletion(^(PNManageMembershipsStatus *status) {
        if (!status.isError) {
            /**
             * UUID's memberships successfully removed.
             * Result object has following information:
             *   status.data.memberships - list of UUID's existing memberships,
             *   status.data.next - cursor bookmark for fetching the next page,
             *   status.data.prev - cursor bookmark for fetching the previous page,
             *   status.data.totalCount - total number of UUID's memberships.
             */
        } else {
            /**
             * Handle UUID's memberships remove error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when remove memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end

The method Set and Remove channel memberships for a user.

To Manage Memberships you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNManageMembershipsRequestYesManage UUID's memberships request with information what modifications to UUID's memberships should be done (set / remove channels).
    blockPNManageMembershipsCompletionBlockNoManage UUID's memberships request completion block.
  1. ParameterTypeRequiredDescription
    setChannelsNSArray<NSDictionary *>NoList of channels within which UUID should be set as member.
    Each entry is dictionary with channel and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    removeChannelsNSArray<NSString *>NoList of channels from which UUID should be removed as member.
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    includeFieldsPNMembershipFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNMembershipsTotalCountField - include how many memberships UUID has.
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership add requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    Default value (PNMembershipsTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNManageMembershipsRequest *request = [PNManageMembershipsRequest requestWithUUID:@"uuid"];
request.setChannels = @[
    @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
];
request.removeChannels = @[@"channel3", @"channel4"];
// Add this request option, if returned membership models should have value which has been set to
// 'custom' and 'channel' properties.
request.includeFields = PNMembershipCustomField | PNMembershipChannelField | PNMembershipsTotalCountField;
request.limit = 40;

[self.client manageMembershipsWithRequest:request
                               completion:^(PNManageMembershipsStatus *status) {

    if (!status.isError) {
        /**
         * UUID's memberships successfully set.
         * Result object has following information:
         *   status.data.memberships - list of UUID's existing memberships,
         *   status.data.next - cursor bookmark for fetching the next page,
         *   status.data.prev - cursor bookmark for fetching the previous page,
         *   status.data.totalCount - total number of UUID's memberships.
         */
    } else {
        /**
         * Handle UUID's memberships set error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when manage memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end
  1. ParameterTypeRequiredDescription
    uuidNSStringNoIdentifier for which memberships should be set.
    Default: configured PubNub client uuid
    setNSArrayNoList of channels for which metadata associated with each of them in context of UUID should be set.

    Each entry is dictionary with channel and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    removeNSArrayNoList of channels from which UUID should be removed as member.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipCustomField - include field with additional information from metadata which has been associated with UUID during membership set requests.
    • PNMembershipChannelField - include channel's metadata into response (not only name).
    • PNMembershipChannelCustomField - include channel's additional information which has been used during channel metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageMembershipsCompletionBlockNoManage UUID's memberships request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
NSArray<NSDictionary *> *setChannels = @[
    @{ @"channel": @"channel1", @"custom": @{ @"role": @"moderator" } }
];
NSArray<NSString *> *removeChannels = @[@"channel3", @"channel4"];

self.client.objects().manageMemberships()
    .uuid(@"uuid")
    .set(setChannels)
    .remove(removeChannels)
    .includeCount(YES)
    .limit(40)
    .includeFields(PNMembershipCustomField | PNMembershipChannelField)
    .performWithCompletion(^(PNManageMembershipsStatus *status) {
        if (!status.isError) {
            /**
             * UUID's memberships successfully set.
             * Result object has following information:
             *   status.data.memberships - list of UUID's existing memberships,
             *   status.data.next - cursor bookmark for fetching the next page,
             *   status.data.prev - cursor bookmark for fetching the previous page,
             *   status.data.totalCount - total number of UUID's memberships.
             */
        } else {
            /**
             * Handle UUID's memberships set error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when manage memberships Object API is used:

@interface PNManageMembershipsData : PNServiceData

// List of existing memberships.
@property (nonatomic, readonly, strong) NSArray<PNMembership *> *memberships;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNMembershipsTotalCountField not added to 'includeFields'
 * of PNSetMembershipsRequest / PNRemoveMembershipsRequest / PNManageMembershipsRequest or
 * PNFetchMembershipsRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageMembershipsStatus : PNAcknowledgmentStatus

// Memberships set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageMembershipsData *data;

@end

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.

To Get Channel Members you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNFetchChannelMembersRequestYesFetch channel's members request with all information which should be used to fetch existing channel's members.
    blockPNFetchChannelMembersCompletionBlockYesFetch channel's members request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsPNChannelMemberFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNChannelMembersTotalCountField - include how many members channel has.
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    Default value (PNChannelMembersTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of members to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNFetchChannelMembersRequest *request = [PNFetchChannelMembersRequest requestWithChannel:@"channel"];
request.start = @"<next from previous request>";
// Add this request option, if returned member models should have value which has been set to
// 'custom' and 'uuid' properties.
request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
request.limit = 40;

[self.client channelMembersWithRequest:request
                            completion:^(PNFetchChannelMembersResult *result, PNErrorStatus *status) {

    if (!status.isError) {
        /**
         * Channel's members successfully fetched.
         * Result object has following information:
         *   result.data.members - list of channel's members,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of channel's members.
         */
    } else {
        /**
         * Handle channel's members fetch error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when fetch members Object API is used:

@interface PNFetchChannelMembersData : PNServiceData

// List of fetched members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of members created for current subscribe key.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchChannelMembersResult : PNAcknowledgmentStatus

// Fetch members request processed information.
@property (nonatomic, readonly, strong) PNFetchChannelMembersData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel from which members should be fetched.
    includeFieldsPNChannelMemberFieldsNo
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNFetchChannelMembersCompletionBlockYesFetch channel's members request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().channelMembers(@"channel")
    .includeCount(YES)
    .limit(40)
    .includeFields(PNChannelMemberCustomField | PNChannelMemberUUIDField)
    .performWithCompletion(^(PNFetchChannelMembersResult *result, PNErrorStatus *status) {
        if (!status.isError) {
            /**
             * Channel's members successfully fetched.
             * Result object has following information:
             *   result.data.members - list of channel's members,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of channel's members.
             */
        } else {
            /**
             * Handle channel's members fetch error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when fetch members Object API is used:

@interface PNFetchChannelMembersData : PNServiceData

// List of fetched members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of members created for current subscribe key.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNFetchChannelMembersResult : PNAcknowledgmentStatus

// Fetch members request processed information.
@property (nonatomic, readonly, strong) PNFetchChannelMembersData *data;

@end

Error resonse which is used in case of Objects API call failure:

@interface PNErrorData : PNServiceData

// Stringified error information.
@property (nonatomic, readonly, strong) NSString *information;

@end
 
@interface PNErrorStatus : PNStatus

// Whether status object represent error or not.
@property (nonatomic, readonly, assign, getter = isError) BOOL error;

// Additional information related to error status object.
@property (nonatomic, readonly, strong) PNErrorData *errorData;

@end

This method sets members in a channel.

To Set Channel Members you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNSetChannelMembersRequestYesSet channel's members list request with information which should be used to set UUID member.
    blockPNManageChannelMembersCompletionBlockNoSet channel's members list request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsPNChannelMemberFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNChannelMembersTotalCountField - include how many members channel has.
    • PNChannelMemberCustomField - field with additional information from metadata which has been associated with UUID during channel member set requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    Default value (PNChannelMembersTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
NSArray>NSDictionary *> *uuids = @[
  @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
];

PNSetChannelMembersRequest *request = [PNSetChannelMembersRequest requestWithChannel:@"channel" uuids:uuids];
// Add this request option, if returned member models should have value which has been set to
// 'custom' and 'uuid' properties.
request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
request.limit = 40;

[self.client setChannelMembersWithRequest:request completion:^(PNManageChannelMembersStatus *status) {
    if (!status.isError) {
        /**
         * Channel's members successfully set.
         * Result object has following information:
         *   result.data.members - list of existing channel's members,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of channel's members.
         */
    } else {
        /**
         * Handle channel's members set error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when set members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel from which members should be set.
    uuidsNSArrayNoList of UUIDs for which metadata associated with each of them in context of channel should be set.

    Each entry is dictionary with UUID and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    includeFieldsPNChannelMemberFieldsNo
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member set requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. Only objects whose properties satisfy the given expression are returned. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageChannelMembersCompletionBlockNoSet channel's members list request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
NSArray<NSDictionary *> *uuids = @[
  @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
];

self.client.objects().setChannelMembers(@"channel")
    .uuids(uuids)
    .includeCount(YES)
    .limit(40)
    .includeFields(PNChannelMemberCustomField | PNChannelMemberUserField)
    .performWithCompletion(^(PNManageChannelMembersStatus *status) {
        if (!status.isError) {
            /**
             * Channel's members successfully set.
             * Result object has following information:
             *   result.data.members - list of existing channel's members,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of channel's members.
             */
        } else {
            /**
             * Handle channel's members set error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when set members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end

Remove members from a Channel.

To Remove Channel Members you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNRemoveChannelMembersRequestYesRemove channel's members request with information which should be used to remove UUID members.
    blockPNManageChannelMembersCompletionBlockNoRemove channel's members request completion block.
  1. ParameterTypeRequiredDescription
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    Use asc or desc to specify sort direction.
    includeFieldsPNChannelMemberFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNChannelMembersTotalCountField - include how many members channel has.
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    Default value (PNChannelMembersTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
NSArray<NSString *> *uuids = @[@"uuid3", @"uuid4"];
PNRemoveChannelMembersRequest *request = [PNRemoveChannelMembersRequest requestWithChannel:@"channel"
                                                                                     uuids:uuids];
// Add this request option, if returned member models should have value which has been set to
// 'custom' and 'uuid' properties.
request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
request.limit = 40;

[self.client removeChannelMembersWithRequest:request completion:^(PNManageChannelMembersStatus *status) {
    if (!status.isError) {
        /**
         * Channel's members successfully removed.
         * Result object has following information:
         *   result.data.members - list of channel's existing members,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of channel's members.
         */
    } else {
        /**
         * Handle channel's members remove error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when remove members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel from which members should be removed.
    uuidsNSArrayNoList of UUIDs which should be removed from channel's list.
    includeFieldsPNChannelMemberFieldsNo
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    includeCountBOOLNoWhether total count of members should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageChannelMembersCompletionBlockNoRemove channel's members request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
self.client.objects().removeChannelMembers(@"channel")
    .uuids(@[@"uuid3", @"uuid4"])
    .includeCount(YES)
    .limit(40)
    .includeFields(PNChannelMemberCustomField | PNChannelMemberUserField)
    .performWithCompletion(^(PNManageChannelMembersStatus *status) {
        if (!status.isError) {
            /**
             * Channel's members successfully removed.
             * Result object has following information:
             *   result.data.members - list of channel's existing members,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of channel's members.
             */
        } else {
            /**
             * Handle channel's members remove error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when remove members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end

The method Set and Remove channel memberships for a user.

To Manage Channel Members you can use the following method(s) in the Cocoa SDK:

  1. ParameterTypeRequiredDescription
    requestPNManageChannelMembersRequestYesManage channel's members list request with information what modifications to channel's members list should be done (set / remove UUID).
    blockPNManageChannelMembersCompletionBlockNoManage channel's members list request completion block.
  1. ParameterTypeRequiredDescription
    setMembersNSArray<NSDictionary *>NoList of UUIDs which should be added to channel's members list.
    Each entry is dictionary with uuid and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    removeMembersNSArray<NSString *>NoBList of UUIDs which should be removed from channel's list.
    sortNSArray<NSString *>NoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    includeFieldsPNChannelMemberFieldsNoBitfield set to fields which should be returned with response.
    Supported fields:
    • PNChannelMembersTotalCountField - include how many members channel has.
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    Default value (PNChannelMembersTotalCountField) can be reset by setting 0.
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    startNSStringNoPreviously-returned cursor bookmark for fetching the next page.
    endNSStringNoPreviously-returned cursor bookmark for fetching the previous page.
    Ignored if you also supply the start parameter.
    limitNSUIntegerNoNumber of objects to return in response.
    Will be set to 100 (which is also maximum value) if not specified.
PNManageChannelMembersRequest *request = [PNManageChannelMembersRequest requestWithChannel:@"channel"];
request.setMembers = @[
    @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
];
request.removeMembers = @[@"uuid3", @"uuid4"];
// Add this request option, if returned member models should have value which has been set to
// 'custom' and 'uuid' properties.
request.includeFields = PNChannelMemberCustomField | PNChannelMemberUUIDField | PNChannelMembersTotalCountField;
request.limit = 40;

[self.client manageChannelMembersWithRequest:request completion:^(PNManageChannelMembersStatus *status) {
    if (!status.isError) {
        /**
         * Channel's members successfully changed.
         * Result object has following information:
         *   result.data.members - list of existing channel's members,
         *   result.data.next - cursor bookmark for fetching the next page,
         *   result.data.prev - cursor bookmark for fetching the previous page,
         *   result.data.totalCount - total number of channel's members.
         */
    } else {
        /**
         * Handle channel's members manage error. Check 'category' property to find out possible
         * issue because of which request did fail.
         *
         * Request can be resent using: [status retry]
         */
    }
}];

Response objects which is returned by client when manage members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end
  1. ParameterTypeRequiredDescription
    channelNSStringYesName of channel from which members should be managed.
    setNSArrayNoList of UUIDs which should be added to channel's members list.

    Each entry is dictionary with UUID and optional custom fields. custom should be dictionary with simple objects: NSString and NSNumber.
    removeNSArrayNoList of UUIDs which should be removed from channel's list.
    includeFieldsPNChannelMemberFieldsNo
    • PNChannelMemberCustomField - include field with additional information from metadata which has been associated with UUID during channel member add requests.
    • PNChannelMemberUUIDField - include UUID's metadata into response (not only identifier).
    • PNChannelMemberUUIDCustomField - include UUID's additional information which has been used during UUID metadata set requests.
    includeCountBOOLNoWhether total count of objects should be included in response or not.
    Default: YES
    filterNSStringNoExpression to filter out results basing on specified criteria. For more details on the supported grammar, check this.
    sortNSArrayNoList of criteria (name of field) which should be used for sorting in ascending order.
    To change sorting order, append :asc (ascending used by default) or :desc (descending) to field name.
    limitNSUIntegerNoMaximum number of objects per fetched page.
    Default: 100 (which is also maximum value)
    startNSStringNoCursor value to navigate to next fetched result page.
    endNSStringNoCursor value to navigate to previous fetched result page.
    Will be ignored if you also supply the start parameter.
    blockPNManageChannelMembersCompletionBlockNoSet channel's members list request completion block.
 This method uses the builder pattern, you can remove the arguments which are optional.
NSArray<NSDictionary *> *setMembers = @[
    @{ @"uuid": @"uuid2", @"custom": @{ @"role": @"moderator" } }
];
NSArray<NSDictionary *> *removeMembers = @[@"uuid3", @"uuid4"];

self.client.objects().manageChannelMembers(@"channel")
    .set(setMembers)
    .remove(removeMembers)
    .includeCount(YES)
    .limit(40)
    .includeFields(PNChannelMemberCustomField | PNChannelMemberUUIDField)
    .performWithCompletion(^(PNManageChannelMembersStatus *status) {
        if (!status.isError) {
            /**
             * Channel's members successfully changed.
             * Result object has following information:
             *   result.data.members - list of existing channel's members,
             *   result.data.next - cursor bookmark for fetching the next page,
             *   result.data.prev - cursor bookmark for fetching the previous page,
             *   result.data.totalCount - total number of channel's members.
             */
        } else {
            /**
             * Handle channel's members manage error. Check 'category' property to find out possible
             * issue because of which request did fail.
             *
             * Request can be resent using: [status retry]
             */
        }
    });

Response objects which is returned by client when manage members Object API is used:

@interface PNManageChannelMembersData : PNServiceData

// List of existing members.
@property (nonatomic, readonly, strong) NSArray<PNChannelMember *> *members;

// Cursor bookmark for fetching the next page.
@property (nonatomic, nullable, readonly, strong) NSString *next;

// Cursor bookmark for fetching the previous page.
@property (nonatomic, nullable, readonly, strong) NSString *prev;

/**
 * Total number of existing objects.
 *
 * Value will be 0 in case if PNChannelMembersTotalCountField not added to 'includeFields'
 * of PNSetChannelMembersRequest / PNRemoveChannelMembersRequest / 
 * PNManageChannelMembersRequest or PNFetchChannelMembersRequest.
 */
@property (nonatomic, readonly, assign) NSUInteger totalCount;

@end
 
 
@interface PNManageChannelMembersStatus : PNAcknowledgmentStatus

// Members set / remove / manage request processed information.
@property (nonatomic, readonly, strong) PNManageChannelMembersData *data;

@end

The filtering language for Objects is similar to the stream filtering language.

Note the following:

  • Date/time properties, such as updated, must be compared to valid date/time strings formatted according to ISO 8601.
  • Custom properties must have the same type as the value used in the expression; it is an error to compare a custom property of one type to a value of another type.
  • Objects that do not have the referenced custom property at all are excluded regardless of the operator or value used in the expression. The null value can be used to filter out objects that do or do not have the referenced custom property.
  • The LIKE operator supports wildcards denoted by the * character. A wildcard matches any sequence of arbitrary Unicode characters, including the empty sequence. The literal asterisk is matched when escaped using the backslash (\) character.
  • Values used with LIKE must be properly encoded just like any other string value. Thus, in order to escape an asterisk, the raw value must contain \\*.
  • The entire expression must be properly URL-encoded when used in the query string.

<expression>           ::= <and_expression> ( "||" <and_expression> )*
<and_expression>       ::= <binary_condition> ( "&&" <binary_condition> )*
<binary_condition>     ::= "!" <binary_condition> | "(" <expression> ")" | <relational_condition>
<relational_condition> ::= <property_path> <relational_operator> <value>
<property_path>        ::= <property_name> ( "." <property_name> )*
<property_name>        ::= <identifier> | "[" <string> "]"
<value>                ::= <string> | <number> | "true" | "false" | "null"

Tokens

<identifier>           ::=  <letter> | "$" | "_" ( <letter> | "$" | "_" | <digit> )*
<relational_operator>  ::= "==" | "!=" | "<=" | ">=" | "<" | ">" | "LIKE"
<string>               ::= <double_quote> ( "\" <double_quote> | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - <double_quote> - "\" )* <double_quote>
                            | "'" ( "\" "'" | "\" <special_char>
                            | "\" "u" <hex_digit> <hex_digit> <hex_digit> <hex_digit>
                            | <unicode_char> - "'" - "\" )* "'"
<number>               ::= ( "+" | "-" )? ( <digit> )* ( "." )? <digit> ( <digit> )* 
                            ( "e" | "E" ( "+" | "-" )? <digit> ( <digit> )* )?
<letter>               ::= Unicode Letter (category; any kind of letter from any language)
<digit>                ::= "0" .. "9"
<hex_digit>            ::= <digit> | "A" .. "F"
<double_quote>         ::= the " character
<unicode_char>         ::= any character in the Unicode range from U+0020 to U+10FFFF inclusive
<special_char>         ::= "\" | "/" | "b" | "f" | "n" | "r" | "t"

The following simple expression returns results whose custom property named public is equal to Boolean true.


custom.public == true

The following date/time comparison returns results that were modified on or after August 31st, 2019 (UTC):


updated >= "2019-08-31T00:00:00Z"

The following compound expression returns results that don't have a description, but do have a non-empty custom label or description property:


description == null && (custom.label != "" || custom.description != "")

The following wildcard expression returns results whose name starts with the letter X:


name LIKE 'X*'

The following escaped wildcard expression returns results whose name contains an asterisk:


name LIKE '*\\**'