Ios5 通过谷歌+;在ios中
我需要在iOS应用程序中集成不同社交媒体的登录。目前,我试图在用户使用google+帐户登录后显示用户名和个人资料图片。同样,我也遵循了以下youtube教程: 从上面的教程中,我成功地进行了登录,但是我没有得到任何用户名和profilepic,它们都返回空值 下面是我在代码中实现的一些重要方法 //Appdelegate.mIos5 通过谷歌+;在ios中,ios5,google-api,google-plus,google-oauth,xcode4.6.3,Ios5,Google Api,Google Plus,Google Oauth,Xcode4.6.3,我需要在iOS应用程序中集成不同社交媒体的登录。目前,我试图在用户使用google+帐户登录后显示用户名和个人资料图片。同样,我也遵循了以下youtube教程: 从上面的教程中,我成功地进行了登录,但是我没有得到任何用户名和profilepic,它们都返回空值 下面是我在代码中实现的一些重要方法 //Appdelegate.m - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDi
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
GPPSignIn *signIn=[GPPSignIn sharedInstance];
signIn.clientID=@"123456789112.apps.googleusercontent.com";
signIn.scopes=@[kGTLAuthScopePlusLogin];
return YES;
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
NSLog(@"openUrl=%@", url);
if([GPPURLHandler handleURL:url sourceApplication:sourceApplication annotation:annotation])
return YES;
return NO;
}
//LoginViewController.h
@interface LoginViewController : UIViewController<GPPSignInDelegate>
- (IBAction)gPlusSignIn:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UIImageView *profileImage;
@property (weak, nonatomic) IBOutlet UILabel *displayName;
@end
请对此提出任何可能的解决方案
提前感谢我能够通过在上的“服务”选项卡下启用“谷歌api”来解决这个问题 我通过在上的“服务”选项卡下启用“谷歌api”解决了这个问题
- (void)viewDidLoad
{
[super viewDidLoad];
[GPPSignIn sharedInstance].delegate=self;
[[GPPSignIn sharedInstance] trySilentAuthentication];
}
//This method is not getting called
-(void)finishedWithAuth:(GTMOAuth2Authentication *)auth error:(NSError *)error
{
[[[GPPSignIn sharedInstance] plusService] executeQuery:[GTLQueryPlus queryForPeopleGetWithUserId:@"me"] completionHandler:^(GTLServiceTicket *ticket, GTLPlusPerson *person, NSError *error)
{
self.profileImage.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:person.image.url]]];
self.displayName.text=person.displayName;
//Prints null in both
NSLog(@"Name:%@, ProfilePic:%@",self.displayName.text,person.image.url);
}];
}
- (IBAction)gPlusSignIn:(UIButton *)sender {
[[GPPSignIn sharedInstance]authenticate];
}