我正在使用Google开发一个iPhone应用程序。
当我尝试登录时,我会得到一个401错误。
我使用了google ios-SDK-1.7.1SDK。
-(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];
}
}下面是截图,有人能帮我吗?

发布于 2014-10-09 11:17:17
正如评论中所提到的,第一个问题已经讨论过这里了。
GPPNativeShareBuilder协议参考的API文档中提到了文本和媒体同时发布的第二个问题。根据本文档,不能将attachImage与setTitle函数结合使用。函数setPrefillText可以解决您的问题。
https://stackoverflow.com/questions/26235833
复制相似问题