使用google帐户登录,使用电子邮件,然后为应用程序iOS创建密码

使用google帐户登录,使用电子邮件,然后为应用程序iOS创建密码,ios,objective-c,google-signin,google-login,googlesigninapi,Ios,Objective C,Google Signin,Google Login,Googlesigninapi,我是iOS开发新手,我想在我的应用程序中使用Google登录,其中电子邮件来自Google帐户,但为应用程序创建了密码,并为应用程序创建了新帐户,并将其存储在服务器上。如何做到这一点?以下是从谷歌登录获取电子邮件的步骤: 步骤1:使用PodPod'Google/SignIn 步骤2:导入#导入(此导入在Swift的桥接头中或在您的控制器中,用于目标c) 添加GIDSignInUIDelegate 步骤3:加载您想要电子邮件的登录视图或屏幕 ==对于Swift=== GIDSignIn.share

我是iOS开发新手,我想在我的应用程序中使用Google登录,其中电子邮件来自Google帐户,但为应用程序创建了密码,并为应用程序创建了新帐户,并将其存储在服务器上。如何做到这一点?

以下是从谷歌登录获取电子邮件的步骤:

步骤1:使用Pod
Pod'Google/SignIn

步骤2:导入
#导入
(此导入在
Swift
的桥接头中或在您的控制器中,用于
目标c

添加
GIDSignInUIDelegate

步骤3:加载您想要电子邮件的登录视图或屏幕

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
步骤4:执行
GIDSignIn

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
第5步:在您的登录视图中使用预先填写的获取电子邮件地址,并根据您的要求添加其他字段,例如密码、确认密码、联系电话等

注意:您还可以使用GIDSignIn共享实例中的currentUser对象

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
希望这对你有帮助


如果你有任何疑问,一定要告诉我

以下是从谷歌登录获取电子邮件的步骤:

步骤1:使用Pod
Pod'Google/SignIn

步骤2:导入
#导入
(此导入在
Swift
的桥接头中或在您的控制器中,用于
目标c

添加
GIDSignInUIDelegate

步骤3:加载您想要电子邮件的登录视图或屏幕

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
步骤4:执行
GIDSignIn

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
第5步:在您的登录视图中使用预先填写的获取电子邮件地址,并根据您的要求添加其他字段,例如密码、确认密码、联系电话等

注意:您还可以使用GIDSignIn共享实例中的currentUser对象

==对于Swift===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
==对于目标C===

GIDSignIn.sharedInstance().signIn()
[[GIDSignIn sharedInstance] signIn];
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
    if (error == nil) {
        // Perform any operations on signed in user here.
        let name = user.profile.name
        let email = user.profile.email
    } else {
        print("\(error.localizedDescription)")
    }
}
 - (void)signIn:(GIDSignIn *)signIn
    didSignInForUser:(GIDGoogleUser *)user
         withError:(NSError *)error{

        if(error == nil){
            NSLog(@"%@",user.profile.name);
            NSLog(@"%@",user.profile.email);
        }else{
            NSLog(@"%@",error.localizedDescription);
        }
}
GIDSignIn.sharedInstance()?.currentUser.profile.email
[[GIDSignIn sharedInstance] currentUser].profile.email
希望这对你有帮助


如果你有任何疑问,一定要告诉我

遵循@Sujit上的分步指导原则我已经这样做了,我已经获取了用户信息,但我想为我的应用程序创建帐户,我必须使用谷歌电子邮件创建密码。你的问题不清楚。如果您正在获取用户信息,那么您应该从中获取用户电子邮件id。您希望密码是什么?@Sujit抱歉,问题不清楚:(电子邮件google id…..创建密码-密码…..确认密码…联系电话-9999999999..所以这里的id将来自google,当它返回到应用程序时,密码将被创建。我希望现在有点清楚:/Sujit上的一步一步指南我已经完成了,我已经获取了用户信息,但我想为其创建帐户为此,我的应用程序必须使用谷歌电子邮件创建密码。您的问题不清楚。如果您正在获取用户信息,则应从中获取用户电子邮件id。您对密码的期望值是多少?@Sujit抱歉,问题不清楚:(电邮谷歌id…。创建密码-密码…。确认密码…联系电话-9999999999..所以这里的id将来自谷歌,密码将在返回应用程序时创建。我希望现在有点清楚:/@ShikhaSharma这不是多少代码,你可以转换成目标c…否则我会在几分钟后转换它小时。我正忙于其他任务。好的,是的,我正在尝试转换,但请同时发布目标c代码,如果我无法转换,我可以使用您的答案:)谢谢您的帮助显示登录视图后会显示一个白色屏幕。然后从google帐户检索数据:(让我们来。@KetanP,我已经登录并获取用户详细信息,但我需要Objective-C中的用户性别详细信息如何获取性别和标识符,请向我推荐任何一个。@ShikhaSharma这不是很多代码,您可以转换为Objective C。否则,我将在几个小时后转换。我正忙于其他任务。。好的,我正在尝试转换rt,但请同时发布目标c代码,如果我无法转换,我可以使用您的答案:)谢谢您的帮助显示登录视图后显示白色屏幕。然后从google帐户检索数据:(让我们来看看。@KetanP,我已经登录并获取了用户详细信息,但我需要Objective-C中的用户性别详细信息。如何获取性别和标识符,请向我推荐任何一种。