Giter Site home page Giter Site logo

sourov2008 / googledrivebrowser Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 3.0 12.67 MB

Goole Drive Download Library for iOS

License: MIT License

Objective-C 93.71% Ruby 6.29%
google-drive-sdk google-drive-ios objective-c swift ios googledrive googledrivebrowser google-drive-api google-drive-download-ios google-drive plist browse appdelegate delegate-methods driver bytes pod google-drive-for-ios

googledrivebrowser's Introduction

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.

 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

  1. Add in AppDelegate.h file

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

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

       #import "SDGDTableViewController.h"
    

Implement the
SDGDTableViewControllerDelegate Once implemented, you'll recieve calls when a file is downloaded or fails to download or progressValue. Like

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

    UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"SDGD"
                                                     bundle:nil];
    SDGDTableViewController *obj=
        [storyboard instantiateViewControllerWithIdentifier:@"SDGDTableViewController"];
    
    obj.delegate = self;
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:obj];
    [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  <GoogleDriveBrowser/SDGDTableViewController.h>
    
  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 = "<YOUR_CLIENT_ID>"
    
  4. Add the following functions into your into your AppDelegate.swift file

    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    return GIDSignIn.sharedInstance().handle(url,
                                            sourceApplication: sourceApplication,
                                            annotation: annotation)
    }
    
    @available(iOS 9.0, *)
    func application(_ app: UIApplication, open url: URL,
                options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
    let sourceApplication = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String
    let annotation = options[UIApplicationOpenURLOptionsKey.annotation]
    return GIDSignIn.sharedInstance().handle(url,
                                            sourceApplication: sourceApplication,
                                            annotation: annotation)
    
}
  1. Add the following lines of code In your desired class

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

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

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

Download Success Call

  /**
   *  Download successfull
   *  Delegate Downloaded Data with File Info.
   *
   */
  - (void)delegateDownloadedFileWithFileDetails: (GTLRDrive_File *)fileInfo downloadedData: (NSData*)data;

Your Customize query

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

Enjoy GoogleDriveBrowser

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.