iOS中的Google登录集成

Since the publishing of my article about Facebook login integration, I have received tons of requests that wanted me to cover some other sign-in methods in iOS.

自从发表有关Facebook登录集成的文章以来,我收到了无数的请求,希望我涵盖iOS中的其他一些登录方法。

After doing a quick search on Google, I found that most of the blog posts that talk about Google Sign-in integration are quite old and might have been outdated.

在Google上进行快速搜索后,我发现大多数有关Google Sign-in集成的博客文章都已经过时,并且可能已经过时。

Therefore, I think it is good for me to create a step-by-step tutorial on how to integrate Google Sign-in into an iOS app so that anyone who is working on the integration can refer to this article to get a clearer picture.

因此,我认为创建关于如何将Google Sign-in集成到iOS应用中的分步教程对我来说是一件好事,以便从事集成工作的任何人都可以参考本文以获得更清晰的图片。

示例应用 (The Sample App)

Throughout this article, I will show you how to configure your Xcode to use the Google Sign-in SDK as well as how to handle UI changes after a user completed the sign-in/sign-out action.

在整篇文章中,我将向您展示如何配置Xcode以使用Google登录SDK,以及在用户完成登录/退出操作后如何处理UI更改。

The following animated GIF showcases what we will achieve at the end of this article.

以下动画GIF展示了我们在本文结尾处将实现的目标。

Google Sign-in integration sample app
Google Sign-in integration sample app
Google登录集成示例应用

With all that being said, let’s buckle up and get right into it!

话虽如此,让我们紧紧抓住它!

Google登录SDK安装 (Google Sign-In SDK Installation)

Just like every other integration, we first must install all the required dependencies. For our sample app, we will use CocoaPods to install the Google Sign-in SDK.

像其他所有集成一样,我们首先必须安装所有必需的依赖项。 对于我们的示例应用程序,我们将使用CocoaPods安装Google登录SDK。

Fire up your terminal and navigate to the location of the sample app. Use the following command to generate a Podfile.

启动您的终端并导航到示例应用程序的位置。 使用以下命令生成Podfile。

After that, open the Podfile created for your sample app and add the following:

之后,打开为您的示例应用程序创建的Podfile并添加以下内容:

pod 'GoogleSignIn'

Here’s how your podfile should look like:

这是您的podfile的外观:

Podfile to install Google Sign-in SDK
Podfile to install Google Sign-in SDK
用于安装Google登录SDK的Podfile

Save the Podfile, head back to the terminal and run the following command:

保存Podfile,回到终端并运行以下命令:

pod install

After the installation is completed, you should see a workspace file (.xcworkspace) has been created for your sample app. Double click the workspace file and launch your sample app in Xcode.

安装完成后,您应该看到已为示例应用程序创建了工作空间文件( .xcworkspace )。 双击工作区文件,然后在Xcode中启动示例应用程序。

To ensure the SDK installation is successful, open AppDelegate.swift and import the SDK.

为确保成功安装SDK,请打开AppDelegate.swift并导入SDK。

import GoogleSignIn

If your sample app is able to build and run without any errors, then you are good to proceed to the next section.

如果您的示例应用程序能够构建并运行而没有任何错误,那么您可以继续进行下一部分。

为Google登录创建OAuth客户端ID (Creating OAuth Client ID for Google Sign-In)

After performing the SDK installation, you will need an OAuth client ID and an iOS URL scheme so that you can continue with the configuration in Xcode.

执行SDK安装后,您将需要OAuth客户端IDiOS UR

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值