The iOS SDK allows you to retrieve, create, and delete shares. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with shares.
This example illustrates a call to createShare:withCompletionHandler:
API. This API call creates a share.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the createShare:withCompletionHandler:
method.createShare:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCCreateShareAPIParams *params = [[PCCreateShareAPIParams alloc] init];
//The name of the share.(optional)
params.name = @"share_name";
PCResourceShareAPIParams *resourceParams = [[PCResourceShareAPIParams alloc] init];
//Name of the resource. (Required)
resourceParams.name = @"resource_name";
//Type of the resource: file/folder/playlist.(optional)
resourceParams.type = @"file";
//Subtype of the resource: image/video/audio.(optional)
resourceParams.subType = @"image";
//Size of the resource. Required in case of file share only.
resourceParams.size = 32345;
//uri of the resource. (required)
resourceParams.location = @"resource_uri";
params.resources = @[resourceParams];
[[PCAPISDK sharedInstance] createShare:params withCompletionHandler:^(PCShareItem *shareItem, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeResourceCreated: {
NSLog(@"Share created successfully");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Create share API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
This example illustrates a call to deleteShare:withCompletionHandler:
API. This API call deletes a share.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the deleteShare:withCompletionHandler:
method.deleteShare:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCDeleteShareAPIParams *deleteParams = [[PCDeleteShareAPIParams alloc] init];
deleteParams.shareUID = @"shareUID"; // The unique ID of the share. (required).
[[PCAPISDK sharedInstance] deleteShare:deleteParams withCompletionHandler:^(PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeNoContent: {
NSLog(@"Provided share deleted successfully");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Delete share API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
This example illustrates a call to fetchShare:withCompletionHandler:
API. This API call returns a list of shares.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the fetchShare:withCompletionHandler:
method.fetchShare:withCompletionHandler:
API call using the code sample in this example.logout
API which the removes the access token stored in the keychain.authenticate:fromViewController:withCompletionHandler:
API to get a new access token.Code Sample
@try {
PCGetShareAPIParams *params = [[PCGetShareAPIParams alloc] init];
[[PCAPISDK sharedInstance] fetchShare:params withCompletionHandler:^(PCShare *share, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSArray *shares = share.shareList;
NSLog(@"List of user created share: %@", shares);
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"Fetch share API failed");
break;
}
}];
}
@catch (NSException *exception) {
NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.