Collaborations is a sophisticated mechanism for managing access to to folders. If you would like to give your users the ability to manage collaborations, we recommend using the Share SDK rather than trying to call these methods yourself. The Share SDK contains UIViewControllers that allow users to manage folder collaborations.
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXFolderCollaborationsRequest *folderCollaborationsRequest = [contentClient collaborationsRequestForFolderWithID:@"folder-id"];
[folderCollaborationsRequest performRequestWithCompletion:^(NSArray *collaborations, NSError *error) {
// If successful, collaborations will be non-nil and contain BOXCollaboration model objects; otherwise, error will be non-nil.
}];
Add a collaborator by email address:
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationCreateRequest *collaborationCreateRequest = [contentClient collaborationAddRequestToFolderWithID:@"folder-id" userLogin:@"[email protected]" role:BOXCollaborationRoleEditor];
[collaborationCreateRequest performRequestWithCompletion:^(BOXCollaboration *collaboration, NSError *error) {
// If successful, collaboration will be non-nil; otherwise, error will be non-nil.
}];
Add a collaborator by Box user-id:
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationCreateRequest *collaborationCreateRequest = [contentClient collaborationAddRequestToFolderWithID:@"folder-id" userID:@"user-id" role:BOXCollaborationRoleEditor];
[collaborationCreateRequest performRequestWithCompletion:^(BOXCollaboration *collaboration, NSError *error) {
// If successful, collaboration will be non-nil; otherwise, error will be non-nil.
}];
Add a group:
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationCreateRequest *collaborationCreateRequest = [contentClient collaborationAddRequestToFolderWithID:@"folder-id" groupID:@"group-id" role:BOXCollaborationRoleEditor];
[collaborationCreateRequest performRequestWithCompletion:^(BOXCollaboration *collaboration, NSError *error) {
// If successful, collaboration will be non-nil; otherwise, error will be non-nil.
}];
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationRemoveRequest *collaborationRemoveRequest = [contentClient collaborationDeleteRequestWithID:@"collaboration-id"];
[collaborationRemoveRequest performRequestWithCompletion:^(NSError *error) {
// If successful, error will be nil.
}];
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationUpdateRequest *collaborationUpdateRequest = [contentClient collaborationUpdateRequestWithID:@"collaboration-id"];
// Update the role
collaborationUpdateRequest.role = BOXCollaborationRoleViewerUploader;
[collaborationUpdateRequest performRequestWithCompletion:^(NSError *error) {
// If successful, error will be nil.
}];
A "Pending Collaboration" represents a user who has not yet accepted the invitation to join a folder as a collaborator. Most users auto-accept invitations, but some do not. This method retrieves the collaboration invitations that the current user has not yet accepted.
BOXContentClient *contentClient = [BOXContentClient defaultClient];
BOXCollaborationPendingRequest *pendingCollaborationsRequest = [contentClient pendingCollaborationsRequest];
[pendingCollaborationsRequest performRequestWithCompletion:^(NSArray *collaborations, NSError *error) {
// If successful, collaborations will be non-nil and contain BOXCollaboration model objects; otherwise, error will be non-nil.
}];