objective-c - 面对 google plus 登录 IOS 的问题

标签 objective-c xcode google-signin

我在集成 google plus 日志时遇到问题 我收到以下错误:

2015-02-17 20:03:39.377 SIR[288:14344] -[__NSDictionaryM gtm_httpArgumentsString]: unrecognized selector sent to instance 0x14d57a20
2015-02-17 20:03:39.383 SIR[288:14344] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM gtm_httpArgumentsString]: unrecognized selector sent to instance 0x14d57a20'

我用来谷歌登录的代码如下:

 -(void) setGooglePlusButtons {
UIButton *googlePlusSignInButton = [UIButton buttonWithType:UIButtonTypeCustom] ;


UIImage *backgroundButtonImage = [UIImage imageNamed:@"google.png"];

googlePlusSignInButton.frame = CGRectMake(0.0f,
                                           400,
                                           150,
                                           50);

googlePlusSignInButton.titleLabel.textColor = [UIColor whiteColor];
googlePlusSignInButton.titleLabel.font = [UIFont boldSystemFontOfSize:11.0f];
googlePlusSignInButton.titleLabel.numberOfLines = 2;

googlePlusSignInButton.titleLabel.shadowColor = [UIColor darkGrayColor];
googlePlusSignInButton.titleLabel.shadowOffset = CGSizeMake(0.0f,
                                                             -1.0f);

[googlePlusSignInButton setTitle:NSLocalizedString(@"", @"")
                         forState:UIControlStateNormal];

[googlePlusSignInButton setBackgroundImage:backgroundButtonImage
                                   forState:UIControlStateNormal];
[self.view addSubview:googlePlusSignInButton];

[googlePlusSignInButton addTarget:self action:@selector(signInGoogle) forControlEvents:UIControlEventTouchUpInside];}

- (void)signInGoogle {
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
signIn.shouldFetchGoogleUserEmail = YES;
signIn.clientID = KclientId;
signIn.scopes = [NSArray arrayWithObjects:kGTLAuthScopePlusLogin,nil];
signIn.actions = [NSArray arrayWithObjects:@"http://schemas.google.com/ListenActivity",nil];
[[GPPSignIn sharedInstance] authenticate];}


- (void)signOut {
[[GPPSignIn sharedInstance] signOut];}

在应用委托(delegate)中

    - (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation {

return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];}

我在顶部声明了 kclientId

static NSString * const KclientId=@"xxxxxxxxxxxxxxx.apps.googleusercontent.com";

我已经试过了,但我找不到问题所在。

最佳答案

我在使用 Swift 时遇到了同样的问题,我认为您必须在build设置上启用一些标志并启用一些库。

  1. 转到build设置/链接/其他链接器标志并添加不带引号的“-ObjC”。这假设您正在使用一些“头文件”来映射 Google 框架和 Swift 方法。

  2. 转到 Build Phases >Link Binary with Librairies > + > 添加其他,转到 de/usr/lib 目录并选择“libz.dylib”

  3. 编译

关于objective-c - 面对 google plus 登录 IOS 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28564024/

相关文章:

ios - 将方法标记为已弃用

ios - 音频文件在后台播放时如何缩略图显示(IOS)?

objective-c - iPhone 上的混音 : Need advice

ios - 如何访问所有 NSLog 语句?

java - 尝试检索从 Google 登录下载的位图时出现 Skia 错误

Flutter - 如何使用 Google Drive API 下载公共(public)文件

android - 使用两个 sha1 key 在 Play 商店中发布后,Google 登录无法正常工作

ios - 如何将标签设置为UICollectionView-SWIFT-同一屏幕上的多个CollectionView

ios - 使用 sqlite3_column_text() 获取整数值

ios - iOS 9 的 NSURLSession/NSURLConnection HTTP 加载失败和其他 AdMob 警告