我不断收到错误消息“未经验证的使用的每日限制超出。持续使用需要注册。”成功登录后第一次。我能够从帐户中获取所有文件。但在那之后我无法考虑到。我错过了什么?我根据google drive developers console
完成了代码AppDelegate.swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Initialize google sign-in
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(String(describing: configureError))")
return true
}
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)
}
DocumentUploadVC.swift
extension DocumentUploadVC : GIDSignInDelegate, GIDSignInUIDelegate {
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!,
withError error: Error!) {
if let error = error {
self.showAlert("Error", message: error.localizedDescription)
self.service.authorizer = nil
} else {
self.service.authorizer = user.authentication.fetcherAuthorizer()
listFiles()
}
}
func listFiles() {
let gDriveList : GDriveFileListingVC = GDriveFileListingVC ()
self.push(gDriveList)
}
}
GDriveFileListingVC.swift
private let scopes = [kGTLRAuthScopeDriveReadonly]
private let service = GTLRDriveService()
func showGoogleDriveData() {
let query = GTLRDriveQuery_FilesList.query()
query.pageSize = 10
service.executeQuery(query,
delegate: self,
didFinish: #selector(displayResultWithTicket(ticket:finishedWithObject:error:))
)
}
// Process the response and display output
@objc func displayResultWithTicket(ticket: GTLRServiceTicket,
finishedWithObject result : GTLRDrive_FileList,
error : NSError?) {
if let error = error {
activityIndicatorBGView?.isHidden = true
activityIndicatorView.stopAnimating()
self.showAlert("Error", message: error.localizedDescription)
return
}
var text = "";
if let files = result.files, !files.isEmpty {
text += "Files:\n"
for file in files {
text += "\(file.name!) (\(file.identifier!))\n"
}
}