经过大量研究后,我在这里发布了我的问题。我在我的应用程序中使用Google登录最新的SDK,并且该应用程序支持iOS 8+。我目前正在使用Xcode 7.2。最近,我的应用被拒绝,原因是许多用户过去经历过的一个非常普遍的原因:
从APPSTORE中
我们注意到,该用户被带到Safari登录或注册帐户,这提供了糟糕的用户体验。具体来说,Google登录会将用户带到Safari进行登录。
下一步
10.6请修改您的应用,以允许用户登录或在该应用中注册帐户。
我们建议实现Safari View Controller API,以在您的应用程序中显示Web内容。Safari View Controller允许显示URL并通过应用程序中的嵌入式浏览器检查证书,以便客户可以验证网页URL和SSL证书以确认他们将登录凭据输入到合法页面中。
结尾
我已经知道这种拒绝,因为苹果已经拒绝了许多使Safari浏览器中的“登录”流程流出的应用程序。以下是一些供参考的链接
https://code.google.com/p/google-plus-platform/issues/detail?id=900
https://github.com/Torsten2217/google-plus-platform/issues / 900
还有一些其他链接,您可以在Internet上轻松找到
2015年5月,Google发布了具有本地网络视图的新SDK。完整的集成过程在http://www.appcoda.com/google-sign-in-how-to/中列出。
它在iOS 8上运行良好,并且还提供了一个控制器。
现在,我使用的是通过CocoaPods https://developers.google.com/identity/sign-in/ios/start安装的最新google sdk,
上面的google链接包含我尝试过的iOS尝试登录示例。现在,它SFSafariViewController
仅在iOS 9中打开本机,但在iOS 8中,登录流程再次从应用程序外部转到Safari浏览器。
苹果评论者在评论中要求使用,SafariViewController
但控件的可用性来自iOS 9及更高版本。这是链接https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller
如何在iOS 8中使用最新的Google sdk实现此目的?
审稿人都没有提及他/她正在测试的iOS版本。
现在任何人都可以帮助我解决这个问题。如何在iOS 8中管理Google登录页面的本机当前控制器。
最后,使用最新的Google+ Sign SDK解决了该问题,该应用程序也获得了Apple的认可。我正在发布适用于iOS 9和iOS 8的解决方案。
使用CocoaPods进行集成。
pod 'Google/SignIn'
要开始登录,您必须执行此处“开始集成”部分中所述的完全相同的步骤。
现在,在“添加登录”部分中,我希望我的自定义类中的一些自定义按钮UIViewController
可以启动登录过程。在Google的开发人员链接中,他们仅在AppDelegate中进行重定向。因此,为避免这种情况,我不会GIDSignInDelegate
在AppDelegate
课堂上使用
我只会在以下两种方法中进行更改 AppDelegate
//This is available for iOS 9 and above. So we have to use this method if we are integrating Google Sign In in iOS 9
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject])
//This is available prior iOS 9 and is available for iOS 8,7 etc. This is a deprecated method for iOS 9. You have to override this too if your app supports iOS 8 platform.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool
因此定义如下:
func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool {
if #available(iOS 9.0, *) {
return GIDSignIn.sharedInstance().handleURL(url, sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as? String, annotation: options[UIApplicationOpenURLOptionsAnnotationKey] as? String)
} else {
// Fallback on earlier versions
}
return true
}
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
return GIDSignIn.sharedInstance().handleURL(url,sourceApplication: sourceApplication,annotation: annotation)
}
现在转到我们的CustomUIViewController
类,即LoginViewController
实现GIDSignInDelegate
和GIDSignInUIDelegate
class LoginViewController: UIViewController, GIDSignInDelegate, GIDSignInUIDelegate {
}
有一个用于Google +登录的自定义UIButton,其定义为
@IBAction func googleLoginButtonPressed(sender: AnyObject) {
// Initialize sign-in
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
//assert(configureError == nil, "Error configuring Google services: \(configureError)")
if configureError != nil {
//Handle your error
}else {
GIDSignIn.sharedInstance().shouldFetchBasicProfile = true
GIDSignIn.sharedInstance().clientID = kClientId
GIDSignIn.sharedInstance().delegate = self
GIDSignIn.sharedInstance().uiDelegate = self
//This did the trick for iOS 8 and the controller is presented now in iOS 8
//We have to make allowsSignInWithBrowser false also. If we dont write this line and only write the 2nd line, then iOS 8 will not present a webview and again will take your flow outside the app in safari. So we have to write both the lines, Line 1 and Line 2
GIDSignIn.sharedInstance().allowsSignInWithBrowser = false //Line 1
GIDSignIn.sharedInstance().allowsSignInWithWebView = true //Line 2
GIDSignIn.sharedInstance().signIn()
}
}
现在,实现Google +登录的委托方法
func signIn(signIn: GIDSignIn!, dismissViewController viewController: UIViewController!) {
self.dismissViewControllerAnimated(true) { () -> Void in
}
}
func signIn(signIn: GIDSignIn!, presentViewController viewController: UIViewController!) {
self.presentViewController(viewController, animated: true) { () -> Void in
}
}
func signIn(signIn: GIDSignIn!, didSignInForUser user: GIDGoogleUser!, withError error: NSError!) {
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 fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
} else {
print("\(error.localizedDescription)")
}
}
func signIn(signIn: GIDSignIn!, didDisconnectWithUser user: GIDGoogleUser!, withError error: NSError!) {
//Perform if user gets disconnected
}
现在,这将在iOS 8和9中都可以使用,而无需将您的应用程序移动到Safari之外以进行Google +登录。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句