The iOS SDK allows you to mark files as favorites, retrieve favorites, and delete favorites. The following examples provide detailed steps that describe how to use supported methods and include code samples to help you get started with favorites.
To remove the favorites tag for a file or folder, call deleteFavorites:withCompletionHandler:
method.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the deleteFavorites:withCompletionHandler:
method.deleteFavorites: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 {
PCDeleteFavoritesAPIParams *params = [[PCDeleteFavoritesAPIParams alloc] init];
params.uri = @"URI of the resource"; // URI of the resource (required)
[[PCAPISDK sharedInstance] deleteFavorites:params withCompletionHandler:^(PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode){
case PCAPIResponseCodeNoContent:
NSLog(@"Unmarked file or folder as favorites.");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
To list favorite files or folders, call getFavorites:withCompletionHandler::
method.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the getFavorites:withCompletionHandler:
method.getFavorites: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 {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of all favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = documentFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of document type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = fileFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of file type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = folderFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of folder type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = audioFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of audio type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = photoFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of photo type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Code Sample
@try {
PCGetFavoritesAPIParams *params = [[PCGetFavoritesAPIParams alloc] init];
params.favResourceType = videoFavoriteResourceType;
[[PCAPISDK sharedInstance] getFavorites:params withCompletionHandler:^(NSArray *favoritesItems, PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode) {
case PCAPIResponseCodeOK: {
NSLog(@"Return list of video type favorite from the user account.");
}
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
To add a favorites tag to a file or folder, call setFavorites:withCompletionHandler:
method.
#import <VerizonCloudAPI/VerizonCloudAPI.h>
PCAPISDK
object and call the setFavorites:withCompletionHandler:
method.setFavorites: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 {
PCSetFavoritesAPIParams *params = [[PCSetFavoritesAPIParams alloc] init];
params.uri = @[@"uri of file or folder"]; // An array contains URI of file and folder. (required)
[[PCAPISDK sharedInstance] setFavorites:params withCompletionHandler:^(PCAPIQueryResponse *response) {
switch (response.urlResponse.statusCode){
case PCAPIResponseCodeNoContent:
NSLog(@"Favorite is set for file or folder");
break;
case PCAPIResponseCodeUnauthorized:
NSLog(@"Session is no longer valid.");
break;
case PCAPIResponseCodeServiceUnavailable:
NSLog(@"Server Unavailable");
break;
default:
NSLog(@"failed. Please try again!");
break;
}
}];
}
@catch (NSException * e) {
NSLog(@"catching %@ reason %@", [e name], [e reason]);
}
Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.