SelectiOSiOSCocoaiOS Swift Objects (BETA) API Reference for Realtime Apps

This SDK has been replaced by a new PubNub Swift SDK written purely in Swift. Check it out here.

Creates a user with the specified properties. Returns the created user object, optionally including the user's custom data object.

To Create a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNCreateUserRequestYesCreate user request with all information about new user which will be passed to PubNub service.
    closurePNCreateUserCompletionBlockNoCreate user request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    externalIdStringNoUser identifier from external service (database, auth service).
    profileUrlStringNoURL at which user's profile available.
    customDictionaryNoAdditional / complex attributes which should be associated to user with specified userId.
    emailStringNoEmail address which should be associated to user with specified userId.
    userIdStringYesUnique identifier for new user entry.
    nameStringYesName which should be associated with new user entry.
let request = PNCreateUserRequest(userID: "user-uuid", name: "Serhii")
request.externalId = "93FVfHUAf4RLu79J7Q3ejLVu"
request.profileUrl = "https://pubnub.com"
request.custom = [ "age": 36 ]
request.email = "support@pubnub.com"

self.client.createUser(with: request, completion: { status in
    if !status.isError {
        /**
         * User successfully created.
         * Created user information available here: status.data.user
         */
    } else {
        /**
         * Handle user create 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 create user Object API is used:

open class PNCreateUserData : PNServiceData {
    // Created user object.
    open var user: PNUser? { get }
}
 
 
open class PNCreateUserStatus : PNAcknowledgmentStatus {
    // Create user request processed information.
    open var data: PNCreateUserData { get }
}

Creates a user with the specified properties. Returns the created user object, optionally including the user's custom data object.

To Create a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesUnique identifier for new user entry.
    nameStringYesName which should be associated with new user entry.
    externalIdStringNoUser identifier from external service (database, auth service).
    profileUrlStringNoURL at which user's profile available.
    customDictionaryNoAdditional / complex attributes which should be associated to user with specified userId.
    emailStringNoEmail address which should be associated to user with specified userId.
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNCreateUserCompletionBlockNoCreate user request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.createUser()
    .userId("user-uuid")
    .name("Serhii")
    .externalId("93FVfHUAf4RLu79J7Q3ejLVu")
    .profileUrl("https://pubnub.com")
    .custom([ "age": 36 ])
    .email("support@pubnub.com")
    .includeFields(PNUserFields.customField)
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * User successfully created.
             * Created user information available here: status.data.user
             */
        } else {
            /**
             * Handle user create 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 create user Object API is used:

open class PNCreateUserData : PNServiceData {
    // Created user object.
    open var user: PNUser? { get }
}
 
 
open class PNCreateUserStatus : PNAcknowledgmentStatus {
    // Create user request processed information.
    open var data: PNCreateUserData { get }
}

Updates a user with the specified properties. Returns the updated user object, optionally including the user's custom data object.

To Update a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNUpdateUserRequestYesUpdate user request with all information which should be updated for existing user.
    closurePNUpdateUserCompletionBlockNoUpdate user request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    externalIdStringNoUser identifier from external service (database, auth service).
    profileUrlStringNoURL at which user's profile available.
    customDictionaryNoAdditional / complex attributes which should be associated to user with specified userId.
    emailStringNoEmail address which should be associated to user with specified userId.
    nameStringYesName which should be associated with new user entry.
    userIdStringYesIdentifier of user which should be updated.
let request = PNUpdateUserRequest(userID: "user-uuid", name: "Serhii")
// Add this request option, if returned user model should have value set to 'custom' property.
request.includeFields = PNUserFields.customField
request.custom = [ "age": 39, "status": "Checking some stuff..." ]
request.name = "David"

self.client.updateUser(with: request, completion: { status in
    if !status.isError {
        /**
         * User successfully updated.
         * Updated user information available here: status.data.user
         */
    } else {
        /**
         * Handle user 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 update user Object API is used:

open class PNUpdateUserData : PNServiceData {
    // Updated user object.
    open var user: PNUser? { get }
}
 
 
open class PNUpdateUserStatus : PNAcknowledgmentStatus {
    // Update user request processed information.
    open var data: PNUpdateUserData { get }
}

Updates a user with the specified properties. Returns the updated user object, optionally including the user's custom data object.

To Update a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesUnique identifier for new user entry.
    nameStringNoName which should be associated with user entry. Name can't be empty or nil.
    externalIdStringNoUser identifier from external service (database, auth service).
    profileUrlStringNoURL at which user's profile available.
    customDictionaryNoAdditional / complex attributes which should be associated to user with specified userId.
    Partial update not available, whole object from previous create / update with changes should be passed.
    emailStringNoEmail address which should be associated to user with specified userId.
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNUpdateUserCompletionBlockNoUpdate user request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.updateUser()
    .userId("user-uuid")
    .name("David")
    .custom([ "age": 39, "status": "Checking some stuff..." ])
    .includeFields(PNUserFields.customField)
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * User successfully updated.
             * Updated user information available here: status.data.user
             */
        } else {
            /**
             * Handle user 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 update user Object API is used:

open class PNUpdateUserData : PNServiceData {
    // Updated user object.
    open var user: PNUser? { get }
}
 
 
open class PNUpdateUserStatus : PNAcknowledgmentStatus {
    // Update user request processed information.
    open var data: PNUpdateUserData { get }
}

Deletes the specified user object.

To Delete a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNDeleteUserRequestYesDelete user request with information about existing user.
    closurePNDeleteUserCompletionBlockNoDelete user request completion closure.
    ParameterTypeRequiredDescription
    userIdStringYesIdentifier of user which should be removed.
let request = PNDeleteUserRequest(userID: "user-uuid")

self.client.deleteUser(with: request, completion: { status in
    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 delete user Object API is used:

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNAcknowledgmentStatus : PNErrorStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Deletes the specified user object.

To Delete a User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesIdentifier of user which should be removed.
    closurePNDeleteUserCompletionBlockNoDelete user request completion closure.
self.client.deleteUser()
    .userId("user-uuid")
    .performWithCompletion({ status in
        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 delete user Object API is used:

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNAcknowledgmentStatus : PNErrorStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns a paginated list of user objects, optionally including each user's custom data object.

To Get Users you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchUsersRequestYesFetch all users request object with all information which should be used to fetch existing users.
    closurePNFetchUsersCompletionBlockYesFetch all users request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    includeCountBoolNoSet to YES to return the total number of users included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of users to be returned in the response.
    Default is 100.
let request = PNFetchUsersRequest()
request.start = "<next from previous request>"
// Add this request option, if returned user model should have value set to 'custom' property.
request.includeFields = PNUserFields.customField
request.includeCount = true
request.limit = 40

self.client.fetchUsers(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * Users successfully fetched.
         * Result object has following information:
         *   result.data.users - list of fetched users
         *   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 users
         */
    } else {
        /**
         * Handle users 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 users Object API is used:

open class PNFetchUsersData : PNServiceData {
    // List of user objects created for current subscribe key.
    open var users: [PNUser] { get }
    
    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }
    
    /**
     * Total number of users created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchUsersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchUsersResult : PNResult {
    // Fetch all users request processed information.
    open var data: PNFetchUsersData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns a paginated list of user objects, optionally including each user's custom data object.

To Get Users you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    includeCountBoolNoSet to YES to return the total number of users included in the paginated response.
    Default is NO.
    limitIntNoThe number of users to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNFetchUserCompletionBlockYesFetch all users request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchUsers()
    .start("<next from previous request>")
    .includeFields(PNUserFields.customField)
    .includeCount(true)
    .limit(40)
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * Users successfully fetched.
             * Result object has following information:
             *   result.data.users - list of fetched users
             *   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 users
             */
        } else {
            /**
             * Handle users 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 users Object API is used:

open class PNFetchUsersData : PNServiceData {
    // List of user objects created for current subscribe key.
    open var users: [PNUser] { get }
    
    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }
    
    /**
     * Total number of users created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchUsersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchUsersResult : PNResult {
    // Fetch all users request processed information.
    open var data: PNFetchUsersData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the specified user object, optionally including the user's custom data object.

To Get User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchUserRequestYesFetch user request with all information which should be used to fetch existing user.
    closurePNFetchUserCompletionBlockYesFetch user request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    userIdStringYesIdentifier of user which should be fetched.
let request = PNFetchUserRequest(userID: "user-uuid")
// Add this request option, if returned user model should have value set to 'custom' property.
request.includeFields = PNUserFields.customField

self.client.fetchUser(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * User successfully fetched.
         * Fetched user information available here: result.data.user
         */
    } else {
        /**
         * Handle user 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 user Object API is used:

open class PNFetchUserData : PNServiceData {
    // Requested user object.
    open var user: PNUser? { get }
}

 
open class PNFetchUserResult : PNResult {
    // Fetch user request processed information.
    open var data: PNFetchUserData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the specified user object, optionally including the user's custom data object.

To Get User you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesIdentifier of user which should be fetched.
    includeFieldsPNUserFieldsNoBitfield with names of fields to be returned with the response. Set to PNUserFields.customField to return the custom field set by a user create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNFetchUserCompletionBlockYesFetch user request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchUser()
    .userId("user-uuid")
    .includeFields(PNUserFields.customField)
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * User successfully fetched.
             * Fetched user information available here: result.data.user
             */
        } else {
            /**
             * Handle user 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 user Object API is used:

open class PNFetchUserData : PNServiceData {
    // Requested user object.
    open var user: PNUser? { get }
}

 
open class PNFetchUserResult : PNResult {
    // Fetch user request processed information.
    open var data: PNFetchUserData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Creates a space with the specified properties. Returns the created space object, optionally including the space's custom data object.

To Create a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNCreateSpaceRequestYesCreate space request with all information about new space which will be passed to PubNub service.
    closurePNCreateSpaceCompletionBlockNoCreate space request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    informationStringNoSpace description information.
    customDictionaryNoAdditional / complex attributes which should be associated to space with specified spaceId.
    spaceIdStringYesUnique identifier for new space entry.
    nameStringYesName which should be associated with new space entry.
let request = PNCreateSpaceRequest(spaceID: "space-uuid", name: "Admin")
request.information = "Administrative space"
request.profileUrl = "https://pubnub.com"
request.custom = [ "responsibilities": "Manage access to protected resources" ]

self.client.createSpace(with: request, completion: { status in
    if !status.isError {
        /**
         * Space successfully created.
         * Created space information available here: status.data.space
         */
    } else {
        /**
         * Handle space create 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 create space Object API is used:

open class PNCreateSpaceData : PNServiceData {
    // Created space object.
    open var space: PNSpace? { get }
}
 
 
open class PNCreateSpaceStatus : PNAcknowledgmentStatus {
    // Create spaces request processed information.
    open var data: PNCreateSpaceData { get }
}

Creates a space with the specified properties. Returns the created space object, optionally including the space's custom data object.

To Create a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesUnique identifier for new space entry.
    nameStringYesName which should be associated with new space entry.
    informationStringNoSpace description information.
    customDictionaryNoAdditional / complex attributes which should be associated to space with specified spaceId.
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNCreateSpaceCompletionBlockNoCreate space request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.createSpace()
    .spaceId("space-uuid")
    .name("Admin")
    .information("Administrative space")
    .custom([ "responsibilities": "Manage access to protected resources" ])
    .includeFields(PNSpaceFields.customField)
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * Space successfully created.
             * Created space information available here: status.data.space
             */
        } else {
            /**
             * Handle space create 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 create space Object API is used:

open class PNCreateSpaceData : PNServiceData {
    // Created space object.
    open var space: PNSpace? { get }
}
 
 
open class PNCreateSpaceStatus : PNAcknowledgmentStatus {
    // Create spaces request processed information.
    open var data: PNCreateSpaceData { get }
}

Updates a space with the specified properties. Returns the updated space object, optionally including the space's custom data object.

To Update a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNUpdateSpaceRequestYesUpdate space request with all information which should be updated for existing space.
    closurePNUpdateSpaceCompletionBlockNoUpdate space request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    informationStringNoSpace description information.
    customDictionaryNoAdditional / complex attributes which should be associated to space with specified spaceId.
    nameStringYesName which should be associated with new space entry.
    spaceIdStringYesIdentifier of space which should be updated.
let request = PNUpdateSpaceRequest(spaceID: "space-uuid", name: "Serhii")
// Add this request option, if returned space model should have value set to 'custom' property.
request.includeFields = PNSpaceFields.customField
request.custom = [ "responsibilities": "Manage tests", "status": "offline" ];
request.name = "Updated space name";

self.client.updateSpace(with: request, completion: { status in
    if !status.isError {
        /**
         * Space successfully updated.
         * Updated space information available here: status.data.space
         */
    } else {
        /**
         * Handle space 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 returned by the client when the update space Object API is used:

open class PNUpdateSpaceData : PNServiceData {
    // Updated space object.
    open var space: PNSpace? { get }
}
 
 
open class PNUpdateSpaceStatus : PNAcknowledgmentStatus {
    // Update space request processed information.
    open var data: PNUpdateSpaceData { get }
}

Updates a space with the specified properties. Returns the updated space object, optionally including the space's custom data object.

To Update a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesUnique identifier for new space entry.
    nameStringNoName which should be associated with space entry.
    Name can't be empty or nil.
    informationStringNoSpace description information.
    customDictionaryNoAdditional / complex attributes which should be associated to space with specified spaceId.
    Partial update not available, whole object from previous create / update with changes should be passed.
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNUpdateSpaceCompletionBlockNoUpdate space request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.updateSpace()
    .spaceId("space-uuid")
    .name("Updated space name")
    .custom([ "responsibilities": "Manage tests", "status": "offline" ])
    .includeFields(PNSpaceFields.customField)
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * Space successfully updated.
             * Updated space information available here: status.data.space
             */
        } else {
            /**
             * Handle space 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 update space Object API is used:

open class PNUpdateSpaceData : PNServiceData {
    // Updated space object.
    open var space: PNSpace? { get }
}
 
 
open class PNUpdateSpaceStatus : PNAcknowledgmentStatus {
    // Update space request processed information.
    open var data: PNUpdateSpaceData { get }
}

Deletes the specified space object.

To Delete a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNDeleteSpaceRequestYesDelete space request with information about existing space.
    closurePNDeleteSpaceCompletionBlockNoDelete space request completion closure.
    ParameterTypeRequiredDescription
    spaceIDStringYesIdentifier of space which should be removed.
let request = PNDeleteSpaceRequest(spaceID: "space-uuid")

self.client.deleteSpace(with: request, completion: { status in
    if !status.isError {
        // Space successfully deleted.
    } else {
        /**
         * Handle space 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 delete space Object API is used:

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNAcknowledgmentStatus : PNErrorStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Deletes the specified space object.

To Delete a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesIdentifier of space which should be removed.
    closurePNDeleteSpaceCompletionBlockNoDelete space request completion closure.
self.client.deleteSpace()
    .spaceId("space-uuid")
    .performWithCompletion({ status in
        if !status.isError {
             // Space successfully deleted.
        } else {
            /**
             * Handle space 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 delete space Object API is used:

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNAcknowledgmentStatus : PNErrorStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the paginated list of space objects, optionally including the space's custom data object.

To Get Spaces you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchSpacesRequestYesFetch all spaces request object with all information which should be used to fetch existing spaces.
    closurePNFetchSpacesCompletionBlockYesFetch all spaces request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    includeCountBoolNoSet to YES to return the total number of spaces included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of spaces to be returned in the response.
    Default is 100.
let request = PNFetchSpacesRequest()
request.start = "<next from previous request>"
// Add this request option, if returned space model should have value set to 'custom' property.
request.includeFields = PNSpaceFields.customField
request.includeCount = true
request.limit = 40

self.client.fetchSpaces(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * Spaces successfully fetched.
         * Result object has following information:
         *   result.data.spaces - list of fetched spaces
         *   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 spaces
         */
    } else {
        /**
         * Handle spaces 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 spaces Object API is used:

open class PNFetchSpacesData : PNServiceData {
    // List of space objects created for current subscribe key.
    open var spaces: [PNSpace] { get }
    
    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }
    
    /**
     * Total number of spaces created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchSpacesRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchSpacesResult : PNResult {
    // Fetch all spaces request processed information.
    open var data: PNFetchSpacesData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the paginated list of space objects, optionally including the space's custom data object.

To Get Spaces you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    includeCountBoolNoSet to YES to return the total number of spaces included in the paginated response.
    Default is NO.
    limitIntNoThe number of spaces to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNFetchSpaceCompletionBlockYesFetch all spaces request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchSpaces()
    .start("<next from previous request>")
    .includeFields(PNSpaceFields.customField)
    .includeCount(true)
    .limit(40)
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * Spaces successfully fetched.
             * Result object has following information:
             *   result.data.spaces - list of fetched spaces
             *   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 spaces
             */
        } else {
            /**
             * Handle spaces 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 spaces Object API is used:

open class PNFetchSpacesData : PNServiceData {
    // List of space objects created for current subscribe key.
    open var spaces: [PNSpace] { get }
    
    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }
    
    /**
     * Total number of spaces created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchSpacesRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchSpacesResult : PNResult {
    // Fetch all spaces request processed information.
    open var data: PNFetchSpacesData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}
 
 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the specified space object, optionally including the space's custom data object.

To Get a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchSpaceRequestYesFetch space request with all information which should be used to fetch existing space.
    closurePNFetchSpaceCompletionBlockYesFetch space request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    spaceIdStringYesIdentifier of space which should be fetched.
let request = PNFetchSpaceRequest(spaceID: "space-uuid")
// Add this request option, if returned space model should have value set to 'custom' property.
request.includeFields = PNSpaceFields.customField

self.client.fetchSpace(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * Space successfully fetched.
         * Fetched space information available here: result.data.space
         */
    } else {
        /**
         * Handle space 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 space Object API is used:

open class PNFetchSpaceData : PNServiceData {
    // Requested space object.
    open var space: PNSpace? { get }
}

 
open class PNFetchSpaceResult : PNResult {
    // Fetch space request processed information.
    open var data: PNFetchSpaceData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Returns the specified space object, optionally including the space's custom data object.

To Get a Space you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesIdentifier of space which should be fetched.
    includeFieldsPNSpaceFieldsNoBitfield with names of fields to be returned with the response. Set to PNSpaceFields.customField to return the custom field set by a space create or update request. Omit this property if you do not want to retrieve the additional attributes.
    closurePNFetchSpaceCompletionBlockYesFetch space request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchSpace()
    .spaceId("space-uuid")
    .includeFields(PNSpaceFields.customField)
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * Space successfully fetched.
             * Fetched space information available here: result.data.space
             */
        } else {
            /**
             * Handle space 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 space Object API is used:

open class PNFetchSpaceData : PNServiceData {
    // Requested space object.
    open var space: PNSpace? { get }
}

 
open class PNFetchSpaceResult : PNResult {
    // Fetch space request processed information.
    open var data: PNFetchSpaceData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Get the specified user's space memberships.

To Get Memberships you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchMembershipsRequestYesFetch user's memberships request with all information which should be used to fetch existing user's memberships.
    closurePNFetchMembershipsCompletionBlockYesFetch user's memberships request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNMembershipFieldsNoBitfield set to fields which should be returned with response.
    • PNMembershipFields.customField - field with additional information which has been associated with user during membership create / update requests.
    • PNMembershipFields.spaceField - field with space's information (not only spaceId).
    • PNMembershipFields.spaceCustomField - field with additional information which has been used during space create / update requests.

    Omit this property if you don't want to retrieve additional attributes.
    includeCountBoolNoSet to YES to return the total number of memberships included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of spaces to be returned in the response.
    Default is 100.
    userIDStringYesIdentifier of user for which memberships should be managed.
let request = PNFetchMembershipsRequest(userID: "user-uuid")
// Add this request option, if returned membership models should have value set to 'custom'
// and 'space' properties.
request.includeFields = PNMembershipFields(arrayLiteral: PNMembershipFields.customField,
                                                         PNMembershipFields.spaceCustomField)
request.includeCount = true
request.limit = 40

self.client.fetchMemberships(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * User's memberships successfully fetched.
         * Result object has following information:
         *   result.data.memberships - list of user'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 user's memberships
         */
    } else {
        /**
         * Handle user'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:

open class PNFetchMembershipsData : PNServiceData {
    // List of fetched memberships.
    open var memberships: [PNMembership] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of memberships created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchMembershipsRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchMembershipsResult : PNAcknowledgmentStatus {
    // Fetch memberships request processed information.
    open var data: PNFetchMembershipsData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Get the specified user's space memberships.

To Get Memberships you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesIdentifier of user for which memberships in spaces should be fetched.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipFields.customField - field with additional information which has been associated with user during membership create / update requests.
    • PNMembershipFields.spaceField - field with space's information (not only spaceId).
    • PNMembershipFields.spaceCustomField - field with additional information which has been used during space create / update requests.
    includeCountBoolNoSet to YES to return the total number of memberships included in the paginated response.
    Default is NO.
    limitIntNoThe number of spaces to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNFetchMembershipsCompletionBlockYesFetch user's memberships request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchMemberships()
    .userId("user-uuid")
    .includeCount(true)
    .limit(40)
    .includeFields(PNMembershipFields(arrayLiteral: PNMembershipFields.customField, 
                                                    PNMembershipFields.spaceField))
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * User's memberships successfully fetched.
             * Result object has following information:
             *   result.data.memberships - list of user'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 user's memberships
             */
        } else {
            /**
             * Handle user'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:

open class PNFetchMembershipsData : PNServiceData {
    // List of fetched memberships.
    open var memberships: [PNMembership] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of memberships created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchMembershipsRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchMembershipsResult : PNAcknowledgmentStatus {
    // Fetch memberships request processed information.
    open var data: PNFetchMembershipsData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Get the specified space’s member users.

To Get Members you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNFetchMembersRequestYesFetch space's members request with all information which should be used to fetch existing space's members.
    closurePNFetchMembersCompletionBlockYesFetch space's members request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNMemberFieldsNoBitfield set to fields which should be returned with response.
    • PNMemberFields.customField - field with additional information which has been associated with user during add / update space's users list requests.
    • PNMemberFields.userField - field with user's information (not only userId).
    • PNMemberFields.userCustomField - field with additional information which has been used during user create / update requests.

    Omit this property if you don't want to retrieve additional attributes.
    includeCountBoolNoSet to YES to return the total number of members included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of members to be returned in the response.
    Default is 100.
    spaceIDStringYesIdentifier of space for which members list should be fetched.
let request = PNFetchMembersRequest(spaceID: "space-uuid")
// Add this request option, if returned member models should have value set to 'custom' and
// 'user' properties.
request.includeFields = PNMemberFields(arrayLiteral: PNMemberFields.customField,
                                                     PNMemberFields.userField)
request.includeCount = true
request.limit = 40

self.client.fetchMembers(with: request, completion: { (result, status) in
    if !status.isError {
        /**
         * Space's members successfully fetched.
         * Result object has following information:
         *   result.data.members - list of space'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 space's members
         */
    } else {
        /**
         * Handle space'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:

open class PNFetchMembersData : PNServiceData {
    // List of fetched members.
    open var members: [PNMember] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of members created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchMembersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchMembersResult : PNAcknowledgmentStatus {
    // Fetch members request processed information.
    open var data: PNFetchMembersData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Get the specified space’s member users.

To Get Members you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesIdentifier of space for which list of members will be fetched.
    includeFieldsPNMemberFieldsNo
    • PNMemberFields.customField - field with additional information which has been associated with user during add / update space's users list requests.
    • PNMemberFields.userField - field with user's information (not only userId).
    • PNMemberFields.userCustomField - field with additional information which has been used during user create / update requests.
    includeCountBoolNoSet to YES to return the total number of members included in the paginated response.
    Default is NO.
    limitIntNoThe number of members to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNFetchMembersCompletionBlockYesFetch space's members request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.fetchMembers()
    .spaceId("space-uuid")
    .includeCount(true)
    .limit(40)
    .includeFields(PNMemberFields(arrayLiteral: PNMemberFields.customField, 
                                                PNMemberFields.userField))
    .performWithCompletion({ (result, status) in
        if !status.isError {
            /**
             * Space's members successfully fetched.
             * Result object has following information:
             *   result.data.members - list of space'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 space's members
             */
        } else {
            /**
             * Handle space'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:

open class PNFetchMembersData : PNServiceData {
    // List of fetched members.
    open var members: [PNMember] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of members created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNFetchMembersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNFetchMembersResult : PNAcknowledgmentStatus {
    // Fetch members request processed information.
    open var data: PNFetchMembersData { get }
}

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

open class PNErrorData : PNServiceData {
    // Stringified error information.
    open var information: String { get }
}

 
open class PNErrorStatus : PNStatus {
    // Whether status object represent error or not.
    open var isError: Bool { get }
    
    // Additional information related to error status object.
    open var data: PNErrorData { get }
}

Manage the specified user's memberships. You can Add, Remove, and Update a user's memberships.

To Manage Memberships you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNManageMembershipsRequestYesManage user's memberships request with information what modifications to user's memberships should be done (join / update / leave spaces).
    closurePNManageMembershipsCompletionBlockNoManage user's memberships request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNMembershipFieldsNoBitfield set to fields which should be returned with response.
    • PNMembershipFields.customField - field with additional information which has been associated with user during membership create / update requests.
    • PNMembershipFields.spaceField - field with space's information (not only spaceId).
    • PNMembershipFields.spaceCustomField - field with additional information which has been used during space create / update requests.

    Omit this property if you don't want to retrieve additional attributes.
    joinSpacesStringNoList of spaces to which user should join.
    Each entry is dictionary with spaceId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    updateSpacesStringNoList of spaces for which additional information associated with user should be updated.
    Each entry is dictionary with spaceId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    leaveSpacesStringNoList of (their identifiers) which user should leave.
    includeCountBoolNoSet to YES to return the total number of memberships included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of memberships to be returned in the response.
    Default is 100.
    userIDStringYesIdentifier of user for which memberships should be managed.
let request = PNManageMembershipsRequest(userID: "user-uuid")
request.updateSpaces = [
    [ "spaceId": "space2-uuid", "custom": [ "role": "moderator" ] ]
]
request.leaveSpaces = ["space3-uuid", "space4-uuid"]
request.joinSpaces = [
    [ "spaceId": "space1-uuid", "custom": [ "role": "owner" ] ]
]
// Add this request option, if returned membership models should have value set to 'custom'
// and 'space' properties.
request.includeFields = PNMembershipFields(arrayLiteral: PNMembershipFields.customField,
                                                         PNMembershipFields.spaceField)
request.includeCount = true
request.limit = 40

self.client.manageMemberships(with: request, completion: { status in
    if !status.isError {
        /**
         * User's memberships successfully updated.
         * Result object has following information:
         *   status.data.memberships - list of user's created / updated 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 user's memberships
         */
    } else {
        /**
         * Handle user's memberships 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 manage memberships Object API is used:

open class PNManageMembershipsData : PNServiceData {
    // List of updated memberships.
    open var memberships: [PNMembership] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of memberships created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNManageMembershipsRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNManageMembershipsStatus : PNAcknowledgmentStatus {
    // Manage memberships request processed information.
    open var data: PNManageMembershipsData { get }
}

Updates the specified user's memberships. You can Add, Remove, and Update a user's memberships.

To Update Memberships you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    userIdStringYesIdentifier of user for which memberships should be managed.
    addArrayNoList of spaces which should be added to user's memberships.
    Each entry is dictionary with spaceId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    updateArrayNoList of spaces for which additional information associated with userId should be updated.
    Each entry is dictionary with spaceId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    removeArrayNoList of spaces (their identifiers) which should be removed from user's memberships.
    includeFieldsPNMembershipFieldsNo
    • PNMembershipFields.customField - field with additional information which has been associated with user during membership create / update requests.
    • PNMembershipFields.spaceField - field with space's information (not only spaceId).
    • PNMembershipFields.spaceCustomField - field with additional information which has been used during space create / update requests.
    includeCountBoolNoSet to YES to return the total number of memberships included in the paginated response.
    Default is NO.
    limitIntNoThe number of memberships to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNManageMembershipsCompletionBlockNoManage user's memberships request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.manageMemberships()
    .userId("user-uuid")
    .update([
        [ "spaceId": "space2-uuid", "custom": [ "role": "moderator" ] ]
    ])
    .remove(["space3-uuid", "space4-uuid"])
    .add([
        [ "spaceId": "space1-uuid", "custom": [ "role": "owner" ] ]
    ])
    .includeCount(true)
    .limit(40)
    .includeFields(PNMembershipFields(arrayLiteral: PNMembershipFields.customField, 
                                                    PNMembershipFields.spaceField))
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * User's memberships successfully updated.
             * Result object has following information:
             *   status.data.memberships - list of user's created / updated 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 user's memberships
             */
        } else {
            /**
             * Handle user's memberships 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 manage memberships Object API is used:

open class PNManageMembershipsData : PNServiceData {
    // List of updated memberships.
    open var memberships: [PNMembership] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of memberships created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNManageMembershipsRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNManageMembershipsStatus : PNAcknowledgmentStatus {
    // Manage memberships request processed information.
    open var data: PNManageMembershipsData { get }
}

Manage the specified space’s member users. You can Add, Remove, and Update a space's members.

To Manage Members you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    requestPNManageMembersRequestYesManage space's members list request with information what modifications to space's members list should be done (add / update / remove users).
    closurePNManageMembersCompletionBlockNoManage space's members list request completion closure.
    ParameterTypeRequiredDescription
    includeFieldsPNMemberFieldsNoBitfield set to fields which should be returned with response.
    • PNMemberFields.customField - field with additional information which has been associated with user during add / update space's users list requests.
    • PNMemberFields.userField - field with user's information (not only userId).
    • PNMemberFields.userCustomField - field with additional information which has been used during user create / update requests.

    Omit this property if you don't want to retrieve additional attributes.
    addMembersStringNoList of users which should be added to space's members list.
    Each entry is dictionary with userId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    updateMembersStringNoList of users for which additional information associated with each of them in context of space should be updated.
    Each entry is dictionary with userId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    removeMembersStringNoList of users which should be removed from members list.
    includeCountBoolNoSet to YES to return the total number of members included in the paginated response.
    Default is NO.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    limitIntNoThe number of members to be returned in the response.
    Default is 100.
    spaceIDStringYesIdentifier of space for which members list should be updated.
let request = PNManageMembersRequest(spaceID: "space-uuid")
request.updateMembers = [
    [ "userId": "user2-uuid", "custom": [ "role": "moderator" ] ]
]
request.removeMembers = ["user3-uuid", "user4-uuid"]
request.addMembers = [
    [ "userId": "user1-uuid", "custom": [ "role": "owner" ] ]
]
// Add this request option, if returned member models should have value set to 'custom' and
// 'user' properties.
request.includeFields = PNMemberFields(arrayLiteral: PNMemberFields.customField,
                                                     PNMemberFields.userField)
request.includeCount = true
request.limit = 40

self.client.manageMembers(with: request, completion: { status in
    if !status.isError {
        /**
         * Space's members successfully updated.
         * Result object has following information:
         *   result.data.members - list of added / updated space'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 space's memebers
         */
    } else {
        /**
         * Handle space's members 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 manage members Object API is used:

open class PNManageMembersData : PNServiceData {
    // List of updated members.
    open var members: [PNMember] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of members created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNManageMembersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNManageMembersStatus : PNAcknowledgmentStatus {
    // Manage members request processed information.
    open var data: PNManageMembersData { get }
}

Update the specified space’s member users. You can Add, Remove, and Update a space's members.

To Update Members you can use the following method(s) in the Swift SDK:
  1. ParameterTypeRequiredDescription
    spaceIdStringYesIdentifier of space for which members list should be updated.
    addArrayNoList of users which should be added to space's members list.
    Each entry is dictionary with userId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    updateArrayNoList of users for which additional information associated with each of them in context of space should be updated.
    Each entry is dictionary with userId and optional custom fields. custom should be dictionary with simple objects: String and Number.
    removeArrayNoList of users (their identifiers) which should be removed from members list.
    includeFieldsPNMemberFieldsNo
    • PNMemberFields.customField - field with additional information which has been associated with user during add / update space's users list requests.
    • PNMemberFields.userField - field with user's information (not only userId).
    • PNMemberFields.userCustomField - field with additional information which has been used during user create / update requests.
    includeCountBoolNoSet to YES to return the total number of members included in the paginated response.
    Default is NO.
    limitIntNoThe number of members to be returned in the response.
    Default is 100.
    startStringNoThe previously-returned cursor bookmark to fetch the next page of results.
    endStringNoThe previously-returned cursor bookmark to fetch the previous page of results.
    closurePNManageMembersCompletionBlockNoManage space's members list request completion closure.
     
    This method uses the builder pattern, you can remove the arguments which are optional.
self.client.manageMembers()
    .spaceId(space-uuid)
    .update([
        [ "userId": "user2-uuid", "custom": [ "role": "moderator" ] ]
    ])
    .remove(["user3-uuid", "user4-uuid"])
    .add([
        [ "userId": "user1-uuid", "custom": [ "role": "owner" ] ]
    ])
    .includeCount(true)
    .limit(40)
    .includeFields(PNMemberFields(arrayLiteral: PNMembershipFields.customField, 
                                                PNMembershipFields.userField))
    .performWithCompletion({ status in
        if !status.isError {
            /**
             * Space's members successfully updated.
             * Result object has following information:
             *   result.data.members - list of added / updated space'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 space's memebers
             */
        } else {
            /**
             * Handle space's members 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 manage members Object API is used:

open class PNManageMembersData : PNServiceData {
    // List of updated members.
    open var members: [PNMember] { get }

    // Cursor bookmark for fetching the next page.
    open var next: String? { get }
    
    // Cursor bookmark for fetching the previous page.
    open var prev: String? { get }

    /**
     * Total number of members created for current subscribe key.
     *
     * Value will be 0 in case if 'includeCount' of PNManageMembersRequest is set to 'false'.
     */
    open var totalCount: Int { get }
}
 
 
open class PNManageMembersStatus : PNAcknowledgmentStatus {
    // Manage members request processed information.
    open var data: PNManageMembersData { get }
}