测试已测试 | ✗ |
语言语言 | Obj-CObjective C |
许可证 | Apache 2 |
发布最新发布 | 2016年11月 |
由Ilan Klein,Oded Betzalel,Anton Aleksandrov,Vitaly M维护。
依赖 | |
Google/SignIn | >= 0 |
BMSSecurity | ~> 2.0 |
这是IBM Bluemix Mobile Services Swift SDK的Google安全组件。
Bluemix Mobile Services Google身份验证 Swift SDK 可通过 Cocoapods 得到。要安装,请将 BMSGoogleAuthentication
pod 添加到您的 Podfile。
use_frameworks!
target 'MyApp' do
platform :ios, '8.0'
pod 'BMSGoogleAuthentication'
end
更新您的 Podfile 后,Pod 的源将添加到您的工作区中。将 GoogleAuthenticationManager.swift
文件从 BMSGoogleAuthentication
pod 的源文件夹复制到您的应用程序文件夹。
然后您需要在其中创建一个桥接头,并添加以下行到其中:
#import <Google/SignIn.h>
完成之后,将您的 "REVERSED_CLIENT_ID"(位于从 Google 开发者控制台获得的 .plist
文件中)和 ".Bundle Identifier" 作为 URL 类型添加到您的项目。
当使用 Xcode 8.x 时,为了使用 BMSGoogleAuthentication,您需要在您的应用程序中启用 Keychain Sharing。您可以在目标的“功能”选项卡中启用此功能。
为了使用Bluemix Mobile Services Google身份验证 Swift SDK,在您希望使用它的类中添加以下导入:
import BMSCore
import BMSSecurity
您移动应用程序与Bluemix服务之间的连接性和交互依赖于与Bluemix应用程序关联的应用程序 ID 和应用程序路由。
BMSClient 和 MCAAuthorizationManager API 是与 SDK 交互的入口点。必须在调用任何其他 API 之前调用以下 API
MCAAuthorizationManager.sharedInstance.initialize(tenantId: tenantId, bluemixRegion: regionName)
通常在这个方法会在您的移动应用程序的应用程序代理中调用。
您还需要将MCAAuthorizationManager定义为您的授权管理器
BMSClient.sharedInstance.authorizationManager = MCAAuthorizationManager.sharedInstance
然后,您必须将Google注册为您身份验证管理器的身份验证代表,方法如下
GoogleAuthenticationManager.sharedInstance.register()
以下代码将openurl请求发送到Google身份验证管理器,需要添加到您的AppDelegate.swift文件中
func application(_ application: UIApplication,
open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return GoogleAuthenticationManager.sharedInstance.handleApplicationOpenUrl(openURL: url, sourceApplication: sourceApplication, annotation: annotation as AnyObject)
}
@available(iOS 9.0, *)
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
return GoogleAuthenticationManager.sharedInstance.handleApplicationOpenUrl(openURL: url, options: options)
}
要注销当前登录用户,必须调用以下代码
GoogleAuthenticationManager.sharedInstance.logout(<callBack>)
当用户尝试再次登录时,将会提示用户授权移动客户端访问使用Google进行身份验证。此时,用户可以点击屏幕右上角的用户名来选择并使用另一位用户登录。
您可以使用 'pod try BMSGoogleAuthentication' 获取示例应用。有关运行示例应用的详细说明在应用程序文件夹中的readme文件中可用。
版权所有 2016 IBM公司。
根据Apache License 2.0版本(以下简称“许可”);除非您明确遵守许可,否则不得使用此文件。您可以在以下地址获得许可证副本:
https://apache.ac.cn/licenses/LICENSE-2.0
除非适用法律要求或书面同意,否则根据本许可分发的软件是在“原样”的基础上分发的,不提供任何明示或暗示的保证或条件。有关本许可规则的具体语言请参见许可。