如何使用google-plus-ios-sdk-1.7.1 sdk登录google-plus? [英] How can I login to google-plus using google-plus-ios-sdk-1.7.1 sdk?

查看:131
本文介绍了如何使用google-plus-ios-sdk-1.7.1 sdk登录google-plus?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Google Plus开发iPhone应用程序。

I am developing an iPhone application using Google Plus.

当我尝试登录时,我收到401错误。

When I try to login, I get a 401 error.

我使用google-plus-ios-sdk-1.7.1 sdk。

I used google-plus-ios-sdk-1.7.1 sdk.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

// Override point for customization after application launch.

    [GPPSignIn sharedInstance].clientID = kClientID;
    // Read Google+ deep-link data.
    [GPPDeepLink setDelegate:self];
    [GPPDeepLink readDeepLinkAfterInstall];    

    return YES;
}

shareviewcontroller

-(void)viewDidLoad
{
    [super viewDidLoad];


    GPPSignIn *signIn                   = [GPPSignIn sharedInstance];
    signIn.shouldFetchGooglePlusUser    = YES;
    signIn.scopes                       = @[ kGTLAuthScopePlusLogin ]; 
    signIn.delegate                     = self;    

    [[GPPSignIn sharedInstance] trySilentAuthentication];

    _shareConfiguration                 = [ShareConfiguration sharedInstance];
    _shareConfiguration.useNativeSharebox = YES;
    //_shareConfiguration.deepLinkEnabled = YES;
    _shareConfiguration.mediaAttachmentEnabled = YES;
}

-(void)btnGoogleShare_Action
{

    if ([GPPSignIn sharedInstance].authentication) {
        id<GPPShareBuilder> shareBuilder = [[GPPShare sharedInstance] nativeShareDialog];
        [(id<GPPNativeShareBuilder>)shareBuilder attachImage:self.imgView.image];
        [(id<GPPNativeShareBuilder>)shareBuilder setTitle:self.dict[@"title"] description:self.dict[@"comment"] thumbnailURL:nil];
        [shareBuilder open];
    }
    else
    {
        AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;

        GPPSignInButton *sign = [[GPPSignInButton alloc] init];

        if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {

            appDelegate.alert = [[UIAlertView alloc] initWithTitle:@"Sign to Google +" message:@"After login to Google+, Please retry again." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Cancel", nil];

            [appDelegate.alert setValue:sign forKey:@"accessoryView"]; //works only in iOS7
        } else {

            appDelegate.alert = [[UIAlertView alloc] initWithTitle:@"Sign to Google +" message:@"After login to Google+, Please retry again.\n\n\n" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Cancel", nil];

            sign.frame = CGRectMake(70, 85, 100, 40);
            [appDelegate.alert addSubview:sign];
        }


        [GPPSignInButton class];
        [appDelegate.alert show];
    }
}




以下是截图,任何人都可以帮助我吗?



Below is a screenshot, can anyone help me?

推荐答案

正如评论中提到的,第一个问题已经在这里进行了讨论。

As it mentioned in the comments, first problem is already discussed here.

GPPNativeShareBuilder Protocol Reference 。根据此文档,您不能使用 attachImage setTitle 函数。函数 setPrefillText 可以解决您的问题。

Second problem about text and media simultaneously post is mentioned in API documentation for GPPNativeShareBuilder Protocol Reference. According to this documentation you can't use attachImage with setTitle function. Function setPrefillText could resolve your issue.

这篇关于如何使用google-plus-ios-sdk-1.7.1 sdk登录google-plus?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆