ios - 用于注册的 gmail 集成
问题描述
我正在尝试集成 gmailsignup 以获取用户详细信息。但不幸的是,应用程序崩溃了,在控制台中我越来越喜欢“原因:'您的应用程序缺少对以下 URL 方案的支持:com.googleusercontent.apps.184175093548-lsh99pp3c7hcglf12e2udcm0vcinjvd9' “如果有人帮助我解决它会很棒。在此先感谢。
//AppDelegate class, which I have written additionally.
import UIKit
import GoogleSignIn
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if let error = error {
print("\(error.localizedDescription)")
} else {
// 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 fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
// ...
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: \[UIApplication.LaunchOptionsKey: Any\]?) -> Bool {
GIDSignIn.sharedInstance().clientID = "184175093548-lsh99pp3c7hcglf12e2udcm0vcinjvd9.apps.googleusercontent.com"
GIDSignIn.sharedInstance().delegate = self
let navigation = UINavigationController()
let mainView = gmail(nibName: "gmail", bundle: nil) //ViewController = Name of your controller
navigation.viewControllers = \[mainView\]
self.window!.rootViewController = navigation
self.window?.makeKeyAndVisible()
// Override point for customization after application launch.
return true
}
func application(_ app: UIApplication, open url: URL, options: \[UIApplication.OpenURLOptionsKey : Any\] = \[:\]) -> Bool {
return GIDSignIn.sharedInstance().handle(url as URL?,
sourceApplication: options\[UIApplication.OpenURLOptionsKey.sourceApplication\] as? String,
annotation: options\[UIApplication.OpenURLOptionsKey.annotation\])
}
//View controller class
import UIKit
import GoogleSignIn
class gmail: UIViewController,GIDSignInUIDelegate {
override func viewDidLoad() {
super.viewDidLoad()
var error: Error?
let signinbtn = GIDSignInButton(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
// Do any additional setup after loading the view.
GIDSignIn.sharedInstance().uiDelegate=self
signinbtn.center = view.center
view.addSubview(signinbtn)
}
func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) {
// myActivityIndicator.stopAnimating()
}
}
解决方案
推荐阅读
- jquery - Html:根据第一个选择器过滤第二个选择器
- java - 连接到 sql server 的 JDBC 问题
- json - 如何使用 Laravel API 功能返回第一个 json 元素?
- java - GSON - 从 JSON 对象中删除 JSON 数据
- kubernetes - Kubernetes 仪表板在使用代理时给出“未经授权”
- git - 为什么我在 osxkeychain 中找不到 git 密码?
- perl - 使用 Perl 的 Soap::Lite 调用简单的 Soap API
- grails - 如何绑定到sqldate?
- asp.net - 使用带有两个数据库的存储过程创建数据集,用于 rdlc 报告 VS2015
- javascript - 如何仅拖放特定选定节点而不影响gojs图表API中的子节点