gpt4 book ai didi

ios - google plus登录正在重定向到ios中的google.com

转载 作者:可可西里 更新时间:2023-11-01 06:14:45 26 4
gpt4 key购买 nike

我按照 google 开发人员文档在我的基本应用程序中实现了一个简单的 google plus (gmail) 登录按钮。但是当我运行代码时,它会转到 google.com。

所以这是我遵循的步骤。

1.创建新的客户端 ID 并将其从 Google 控制台添加到应用程序中。2.导入框架3.当我运行代码时,我可以看到

它首先打开谷歌登录页面然后它会打开 Oauth 页面如果我按下“允许”访问然后它会从“accounts.google.com”重定向到“google.com”。

我已经为此创建了一个示例项目

Here是我的代码和屏幕截图enter image description here

enter image description here

enter image description here

enter image description here

我的文件和框架列表 enter image description here

代码

AppDelegate.m

#import <GooglePlus/GooglePlus.h>
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (BOOL)application: (UIApplication *)application
openURL: (NSURL *)url
sourceApplication: (NSString *)sourceApplication
annotation: (id)annotation {
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}

ViewController.h

#import <UIKit/UIKit.h>
#import <GooglePlus/GooglePlus.h>
@class GPPSignInButton;
@interface ViewController : UIViewController<GPPSignInDelegate>

@property (strong, nonatomic) IBOutlet GPPSignInButton *signInButton;

@end

ViewController.m

//
#import <GooglePlus/GooglePlus.h>

#import "ViewController.h"
#import <GoogleOpenSource/GoogleOpenSource.h>
#define kClientId @"49781846815-pbsb1vso4nrbes9a4al5kae2d98ie3cf.apps.googleusercontent.com"
#define kGTLAuthScopePlusLogin @"https://www.googleapis.com/auth/plus.login"
@interface ViewController ()

@end

@implementation ViewController
@synthesize signInButton;

- (void)viewDidLoad {
[super viewDidLoad];
GPPSignIn *signIn = [GPPSignIn sharedInstance];

// Do any additional setup after loading the view, typically from a nib.
signIn.shouldFetchGooglePlusUser = YES;
signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email

// You previously set kClientId in the "Initialize the Google+ client" step
signIn.clientID = kClientId;

// Uncomment one of these two statements for the scope you chose in the previous step
signIn.scopes = @[ kGTLAuthScopePlusLogin ]; // "https://www.googleapis.com/auth/plus.login" scope
signIn.scopes = @[ @"profile" ]; // "profile" scope

// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;

}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error {
NSLog(@"Received error %@ and auth object %@",error, auth);
if (error) {
// Do some error handling here.
} else {
[self refreshInterfaceBasedOnSignIn];
}
}
-(void)refreshInterfaceBasedOnSignIn {
if ([[GPPSignIn sharedInstance] authentication]) {
// The user is signed in.
NSLog(@"hi");
self.signInButton.hidden = YES;
// Perform other actions here, such as showing a sign-out button
} else {
self.signInButton.hidden = NO;
// Perform other actions here
}
}

- (void)presentSignInViewController:(UIViewController *)viewController {
// This is an example of how you can implement it if your app is navigation-based.
[[self navigationController] pushViewController:viewController animated:YES];
}
@end

请帮助解决此 google.com 重定向问题并开发一个良好的登录。

最佳答案

截至 2015 年 5 月,即使您成功运行,您的应用也会被 Apple 的 App Store 审核团队拒绝,因为 Apple 和 Google 之间正在进行幼稚的斗争。在 Google+ SDK 中查看此问题:https://code.google.com/p/google-plus-platform/issues/detail?id=900

关于ios - google plus登录正在重定向到ios中的google.com,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27087645/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com