OStack程序员社区-中国程序员成长平台

标题: ios - 如何使用 google-plus-ios-sdk-1.7.1 sdk 登录 google-plus? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 11:58
标题: ios - 如何使用 google-plus-ios-sdk-1.7.1 sdk 登录 google-plus?

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

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

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

-(BOOL)applicationUIApplication *)application didFinishLaunchingWithOptionsNSDictionary *)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];
    }
}



下面是截图,谁能帮帮我?


http://i.stack.imgur.com/yEv2x.png



Best Answer-推荐答案


正如评论中提到的,第一个问题已经讨论过 here .

关于文本和媒体同时发布的第二个问题在 API 文档中提到 GPPNativeShareBuilder Protocol Reference .根据此文档,您不能将 attachImagesetTitle 函数一起使用。 setPrefillText 函数可以解决您的问题。

关于ios - 如何使用 google-plus-ios-sdk-1.7.1 sdk 登录 google-plus?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26235833/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4