1

ログインを iOS アプリケーションのさまざまなソーシャル メディアに統合する必要があります。現在、ユーザーがGoogle +アカウントでログインすると、 UserName と profilePic Image を表示しようとしています。同じことについて、以下のYouTubeチュートリアルに従いました: http://www.youtube.com/watch?v=M6ro0mib31M

上記のチュートリアルから、私はログインを行うことができましたが、ユーザー名とプロフィール画像を取得できず、両方とも null 値を返しています。

以下は、コードに実装した重要なメソッドの一部です

//Appdelegate.m

- (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

//LoginViewController.m

- (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];
}

これに対する可能な解決策を提案してください。

前もって感謝します

4

1 に答える 1

1

https://code.google.com/apis/consoleのサービス タブで「Google api」を有効にすることで、問題を解決できました。

于 2013-10-01T06:08:41.987 に答える