【发布时间】:2018-05-07 04:45:05
【问题描述】:
在这里我已经集成了 Braintree PayPal 和 google 登录集成,然后我在应用程序委托类中实现了代码,但是两个代码具有相同的功能并显示错误 Invalid redeclaration of 'application(_:open:options:)' 任何人都可以帮助我如何避免这种情况?
这是我的代码
import UIKit
import Braintree
import GoogleSignIn
//import GoogleMaps
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate,GIDSignInDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
BTAppSwitch.setReturnURLScheme("com.ewallsolutions.basic.Gometoo.payments")
IQKeyboardManager.shared.enable = true
GIDSignIn.sharedInstance().delegate = self
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
if url.scheme?.localizedCaseInsensitiveCompare("com.ewallsolutions.basic.Gometoo.payments") == .orderedSame {
return BTAppSwitch.handleOpen(url, options: options)
}
return false
}
@available(iOS 9.0, *)
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,
sourceApplication:options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: [:])
}
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if (error == nil) {
// Perform any operations on signed in user here.
let userId = user.userID // For client-side use only!
let idToken = user.authentication.idToken // Safe to send to the server
let name = user.profile.name
let email = user.profile.email
let userImageURL = user.profile.imageURL(withDimension: 200)
}
else
{
print("\(error.localizedDescription)")
}
}
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user:GIDGoogleUser!,
withError error: NSError!)
{
print("user disconnected")
// Perform any operations when the user disconnects from app here.
// ...
}
【问题讨论】: