About Account Information

About Account Information

Contents

Introduction

To retrieve the information about the user’s account, call fetchAccountInfoWithCompletionHandler: method.

  1. If you have not done that already, add Cloud SDK framework for IOS to an existing or a new IOS application.
  2. Include VerizonCloudAPI.framework header file in you class: #import <VerizonCloudAPI/VerizonCloudAPI.h>
  3. Initalize the PCAPISDK object and call the fetchAccountInfoWithCompletionHandler: method.
  4. Perform the fetchAccountInfoWithCompletionHandler: API call using the code sample in this example.
  5. Obtain the result from the completion block.
  6. If the session is no longer valid:
    1. Call the logout API which the removes the access token stored in the keychain.
    2. Call authenticate:fromViewController:withCompletionHandler: API to get a new access token.

Example

Code Sample

       @try {
            
            [[PCAPISDK sharedInstance] fetchAccountInfoWithCompletionHandler:^(PCAccountInfo *accountInfo, PCAPIQueryResponse *response) {
                
                switch (response.urlResponse.statusCode) {
                    case PCAPIResponseCodeOK: {
                        NSLog(@"Account ID: %@", accountInfo.ID);
                        NSLog(@"Account alias: %@", accountInfo.alias);
                        NSLog(@"Total quota space available in account: %lld", accountInfo.quota);
                        NSLog(@"Total quota space used in account: %lld", accountInfo.quotaUsed);
                    }
                        break;
                    case PCAPIResponseCodeUnauthorized:
                        NSLog(@"Session is no longer valid");
                        break;
                    case PCAPIResponseCodeServiceUnavailable:
                        NSLog(@"Server Unavailable");
                        break;
                    default:
                        NSLog(@"Fetch account info API failed");
                        break;
                }
            }];
        }
        @catch (NSException *exception) {
            NSLog(@"Catching %@ reason %@", [exception name], [exception reason]);
        }
    

Copyright © 2015-2017, Verizon and/or its Licensors. All rights reserved.