Goole Drive Download Library for iOS
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.
Download success toast
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.
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
In folder case recursively browse untill file not found.
Learn more about the project requirements, licensing, contributions, and setup.
Greater than or eqaul iOS 9
Any contribution is more than welcome! You can contribute through pull requests and issues on GitHub.
Follow the instructions below to properly integrate GoogleDriveBrowser into your project.
pod ‘GoogleDriveBrowser’
Configure Google Drive (Follow the Step 1)Turn on the Drive API and setup your app. Follow the Step 1
Drag and drop downloaded Credentials.plist file into your project
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.
Add in AppDelegate.h file
#import <Google/SignIn.h>
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];
}
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>
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];
Add the following line into your into your Bridging header file
Add the following line into your into your AppDelegate.swift file
import Google
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 = “
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)
}
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
Open GoogleDriveBrowser.xcworkspace file and run the project.
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