项目作者: sourov2008

项目描述 :
Goole Drive Download Library for iOS
高级语言: Objective-C
项目地址: git://github.com/sourov2008/GoogleDriveBrowser.git
创建时间: 2018-03-20T15:39:04Z
项目社区:https://github.com/sourov2008/GoogleDriveBrowser

开源协议:MIT License

下载


googledrivebanner

GoogleDriveBrowser provides a simple and effective way to browse, and download files using the Google Drive SDK. In a few minutes you can install Google Drive Browser to configure google credential first.

Features

  • Google Drive browse and Download file .
  • There is a default query for fetching file but you may customise your query .
  • You may open your file with browser(safari).
  • Pull to refresh
  • Download progress shown (Both both progressbar and label)
  • Download success toast

    User Interface

    GoogleDriveBrowser has a simple UITableView interface . You can customise cell icon and donwload icon . By default there is a file fetching Loading indicator , Download progress bar with donwload progress text . Added tableview pull to refresh and file overview.

    googledrivebrowser

    Files

    When a user taps on download button file will download and called the delegate method while downloading file .Also Called delegate method both success/failoure completion

    Folder

    In folder case recursively browse untill file not found.

    Project Details

    Learn more about the project requirements, licensing, contributions, and setup.

    Requirements

    Greater than or eqaul iOS 9

Contributions

Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.

Installation - Via Cocoapods

Follow the instructions below to properly integrate GoogleDriveBrowser into your project.

  1. pod GoogleDriveBrowser

Google Configuration (Both Objective C and Swift)

  1. Configure Google Drive (Follow the Step 1)Turn on the Drive API and setup your app. Follow the Step 1

  2. Drag and drop downloaded Credentials.plist file into your project

  3. Open the Credentials.plist file, and look for the REVERSED_CLIENT_ID key. Copy the value of that key, and paste it into the URL Schemes box on the configuration view.

    Setup in Obj C

  4. Add in AppDelegate.h file

    1. #import <Google/SignIn.h>
  5. In Appdelegate.m file add the following lines of code . Replace YOUR_CLIENT_ID with your CLIENT_ID from credentials.plist file.

    1. - (BOOL)application:(UIApplication *)application
    2. didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    3. // Initialize Google sign-in.
    4. #warning relpace the string with your CLIENT_ID from credentials.plist
    5. [GIDSignIn sharedInstance].clientID = @"<YOUR_CLIENT_ID>";
    6. return YES;
    7. }
    8. - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    9. return [[GIDSignIn sharedInstance] handleURL:url sourceApplication:sourceApplication annotation:annotation];
    10. }
  6. in your desired class in .h file add following code

    1. #import "SDGDTableViewController.h"

    Implement the

    1. `SDGDTableViewControllerDelegate`

    Once implemented, you’ll recieve calls when a file is downloaded or fails to download or progressValue. Like

    1. @interface YourClassName : UIViewController <SDGDTableViewControllerDelegate>
  1. in your desired class in .m file add this line of code

    1. UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"SDGD"
    2. bundle:nil];
    3. SDGDTableViewController *obj=
    4. [storyboard instantiateViewControllerWithIdentifier:@"SDGDTableViewController"];
    5. obj.delegate = self;
    6. UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:obj];
    7. [self presentViewController:nav animated:YES completion:nil];

    Setup in Swift

    Follow the Steps in Google Configuration (Both Objective C and Swift)

    1. Add the following line into your into your Bridging header file

      import

    2. Add the following line into your into your AppDelegate.swift file

      import Google

    3. Add the following line into your into your applicationDidFinishLaunching function in AppDelegate.swift file .Replace YOUR_CLIENT_ID with your CLIENT_ID from credentials.plist file.

      GIDSignIn.sharedInstance().clientID = “

  1. Add the following functions into your into your AppDelegate.swift file

    1. func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    2. return GIDSignIn.sharedInstance().handle(url,
    3. sourceApplication: sourceApplication,
    4. annotation: annotation)
    5. }
    6. @available(iOS 9.0, *)
    7. func application(_ app: UIApplication, open url: URL,
    8. options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    9. let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String
    10. let annotation = options[UIApplicationOpenURLOptionsKey.annotation]
    11. return GIDSignIn.sharedInstance().handle(url,
    12. sourceApplication: sourceApplication,
    13. annotation: annotation)

    }

  2. Add the following lines of code In your desired class

    1. var obj = SDGDTableViewController() ;
    2. let storyboard : UIStoryboard = UIStoryboard(name: "SDGD", bundle: nil)
    3. obj = storyboard.instantiateViewController(withIdentifier: "SDGDTableViewController") as! SDGDTableViewController
    4. obj.delegate = self
    5. let nav = UINavigationController.init(rootViewController: obj)
    6. self.present(nav, animated: true, completion: {
    7. })

    By Default library image will load on google file view . You may change those images

Installation - Manual (Both Objective C and Swift)

  • Download the project and add SDGDTableViewController.h and SDGDTableViewController.m file in your project
  • Follow this step given above ### Google Configuration (Both Objective C and Swift)
  • include those library via pod
  • pod ‘GoogleAPIClientForREST/Drive’, ‘~> 1.2.1’
  • pod ‘Google/SignIn’, ‘~> 3.0.3’

Example Project Run

  • Download GoogleDriveBrowser
  • Install the podfile of Example folder
  • Follow Google Configure Setups
  • Open GoogleDriveBrowser.xcworkspace file and run the project.

    Delegate Methods

    Most important delegates methods are given here . See more delegate methods on SDGDTableViewController.h file

byte by byte download progress call

  1. /**
  2. * File download Progress value . You may use your own progressbar presentation depends on this values
  3. * @param downloaded is download data size instant thread
  4. * @param totalDownloaded is Total downloaded data size
  5. * @param fileInfo from file info you may get file size
  6. */
  7. - (void)delegateDownloadProgress: (GTLRDrive_File *)fileInfo downloadByte:(float)downloaded totalRecived : (float)totalDownloaded;

Download Success Call

  1. /**
  2. * Download successfull
  3. * Delegate Downloaded Data with File Info.
  4. *
  5. */
  6. - (void)delegateDownloadedFileWithFileDetails: (GTLRDrive_File *)fileInfo downloadedData: (NSData*)data;

Your Customize query

  1. /**
  2. * Returns Query parameter. Like this format
  3. * query.fields = @"kind,nextPageToken,files(mimeType,id,kind,name,webViewLink,thumbnailLink,fileExtension,size, createdTime,modifiedTime)";
  4. * query.pageSize = 1000;
  5. * @param folderID is required for query coommand Like In parents 'folderID'
  6. *
  7. */
  8. - (GTLRDriveQuery_FilesList *)delegateSetQueryWithFolderID : (NSString*)folderID;

Enjoy GoogleDriveBrowser