您好我正在尝试在我的iOS应用中集成google + login。我已按照此link的说明进行操作。
示例工作正常,但是当我尝试在我的应用上实现时,它就是这个
errorTerminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSBundle gpp_registerFonts]: unrecognized selector sent to class 0x16af620'
我添加了以下框架 Image 任何帮助
代码:在我的视图的viewdidload中
GPPSignIn *signIn = [GPPSignIn sharedInstance];
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;
signIn.scopes = [NSArray arrayWithObjects:
kGTLAuthScopePlusLogin, // defined in GTLPlusConstants.h
nil];
// Optional: declare signIn.actions, see "app activities"
signIn.delegate = self;
之后我添加了这个功能
- (BOOL)application: (UIApplication *)application openURL: (NSURL *)url sourceApplication: (NSString *)sourceApplication annotation: (id)annotation
{
return [GPPURLHandler handleURL:url
sourceApplication:sourceApplication
annotation:annotation];
}
- (void)finishedWithAuth: (GTMOAuth2Authentication *)auth
error: (NSError *) error
{
NSLog(@"Received error %@ and auth object %@",error, auth);
}
我在类GPPSignInButton的视图中添加了一个按钮。
答案 0 :(得分:10)
问题出在-ObjC上。虽然我之前添加了-ObjC,但我知道为什么它不起作用但是当我删除并再次添加它开始工作。也许我先复制粘贴它,以便有任何空间或其他东西。
答案 1 :(得分:3)
在app委托中你需要设置客户端ID,一旦你设置了这个你不需要在ViewController中重新设置它
你添加了GooglePlus.bundle
如果没有添加,请将它添加到你的项目中
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[GPPSignIn sharedInstance].clientID = kGoogleplusClientID;
[GPPDeepLink setDelegate:self];
......
}
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
return [GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation];
}
你的myView中的下一个你可以做这样的事情
//in .h file
@class GPPSignInButton;
@interface ViewController : UIViewController
@property (retain, nonatomic) IBOutlet GPPSignInButton *signInButton; //sign in button
.....
//in .m file
- (void)viewDidLoad
{
[GPPSignInButton class]; //for sign in button u need to put a view and set its calss name as `GPPSignInButton` and connect to IBOutlet of ur signInButton
[GPPSignIn sharedInstance].shouldFetchGoogleUserEmail = YES;
[GPPSignIn sharedInstance].shouldFetchGooglePlusUser = YES;
GPPSignIn *signIn = [GPPSignIn sharedInstance];
signIn.delegate = self;
........
//if u are settings are all correct u will logged in successfully
}
答案 2 :(得分:0)
我认为您正在使用带有IBOutlet连接的自定义按钮。删除Storyboard中的插座连接,然后重试。它会起作用。