gpt4 book ai didi

ios - 尝试在 iOS 中获取 Google 日历时,控制台显示奇怪的 api#channel 冲突。怎么解决?

转载 作者:可可西里 更新时间:2023-11-01 05:53:35 26 4
gpt4 key购买 nike

我正在尝试构建一个应用程序来获取 Google 日历信息,例如日历、事件等,但我遇到了一个大问题。

这是我的代码:

#define GoogleClientID    @"client id"
#define GoogleClientSecret @"secret"
#define GoogleAuthURL @"https://accounts.google.com/o/oauth2/auth"
#define GoogleTokenURL @"https://accounts.google.com/o/oauth2/token"

NSString *const kKeychainItemName = @"Calendar Panel: Google Calendar";

- (instancetype)initWithViewController: (UIViewController*) viewController;
{
self = [super init];
if (self) {
_viewController = viewController;

}
return self;
}

- (BOOL)isSignedIn {
NSString *name = [self signedInUsername];
return (name != nil);
}

- (NSString *)signedInUsername {
// Get the email address of the signed-in user
GTMOAuth2Authentication *auth = self.calendarService.authorizer;
BOOL isSignedIn = auth.canAuthorize;
if (isSignedIn) {
return auth.userEmail;
} else {
return nil;
}
}

- (GTMOAuth2Authentication * )authForGoogle
{
//This URL is defined by the individual 3rd party APIs, be sure to read their documentation

NSURL * tokenURL = [NSURL URLWithString:GoogleTokenURL];
// We'll make up an arbitrary redirectURI. The controller will watch for
// the server to redirect the web view to this URI, but this URI will not be
// loaded, so it need not be for any actual web page. This needs to match the URI set as the
// redirect URI when configuring the app with Instagram.
NSString * redirectURI = @"urn:ietf:wg:oauth:2.0:oob";
GTMOAuth2Authentication * auth;

auth = [GTMOAuth2Authentication authenticationWithServiceProvider:@"lifebeat"
tokenURL:tokenURL
redirectURI:redirectURI
clientID:GoogleClientID
clientSecret:GoogleClientSecret];
auth.scope = @"https://www.googleapis.com/auth/userinfo.profile";
return auth;
}


- (void)signInToGoogle
{
if (![self isSignedIn]) {

GTMOAuth2Authentication * auth = [self authForGoogle];


// Display the authentication view
GTMOAuth2ViewControllerTouch * viewController = [[GTMOAuth2ViewControllerTouch alloc] initWithAuthentication:auth
authorizationURL:[NSURL URLWithString:GoogleAuthURL]
keychainItemName:@"GoogleKeychainName"
delegate:self
finishedSelector:@selector(viewController:finishedWithAuth:error:)];
[[self.viewController navigationController] pushViewController:viewController animated:YES];
} else
NSLog(@"Something wrong with the sign in procedure!");
}


- (void)viewController:(GTMOAuth2ViewControllerTouch * )viewController
finishedWithAuth:(GTMOAuth2Authentication * )auth
error:(NSError * )error
{
NSLog(@"finished");
NSLog(@"auth access token: %@", auth.accessToken);
self.calendarService.authorizer = auth;

[[self.viewController navigationController] popToViewController:self.viewController animated:NO];
if (error != nil) {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Error Authorizing with Google"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} else {

UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Success Authorizing with Google"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
}

- (void)fetchCalendarList {
self.calendarList = nil;
self.calendarListFetchError = nil;

GTLServiceCalendar *service = self.calendarService;


GTLQueryCalendar *query = [GTLQueryCalendar queryForCalendarListList];

self.calendarListTicket = [service executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
id calendarList, NSError *error) {
// Callback
self.calendarList = calendarList;
self.calendarListFetchError = error;
self.calendarListTicket = nil;

NSLog(@"Fetched number of calendars: %@", self.calendarList);
//[self updateUI];
}];

//[self updateUI];
}

- (GTLServiceCalendar *)calendarService {
static GTLServiceCalendar *service = nil;

if (!service) {
service = [[GTLServiceCalendar alloc] init];

// Have the service object set tickets to fetch consecutive pages
// of the feed so we do not need to manually fetch them
service.shouldFetchNextPages = YES;

// Have the service object set tickets to retry temporary error conditions
// automatically
service.retryEnabled = YES;
}
return service;
}

@end

这是控制台输出:

2014-09-10 23:57:53.603 CalendarPanel[24383:60b] GTLDriveChannel (api#channel) registration conflicts with GTLCalendarChannel
2014-09-10 23:57:53.607 CalendarPanel[24383:60b] GTLPlusDomainsAcl (plus#acl) registration conflicts with GTLPlusAcl
2014-09-10 23:57:53.607 CalendarPanel[24383:60b] GTLPlusDomainsActivity (plus#activity) registration conflicts with GTLPlusActivity
2014-09-10 23:57:53.608 CalendarPanel[24383:60b] GTLPlusDomainsActivityFeed (plus#activityFeed) registration conflicts with GTLPlusActivityFeed
2014-09-10 23:57:53.608 CalendarPanel[24383:60b] GTLPlusDomainsComment (plus#comment) registration conflicts with GTLPlusComment
2014-09-10 23:57:53.609 CalendarPanel[24383:60b] GTLPlusDomainsCommentFeed (plus#commentFeed) registration conflicts with GTLPlusCommentFeed
2014-09-10 23:57:53.609 CalendarPanel[24383:60b] GTLPlusPeopleFeed (plus#peopleFeed) registration conflicts with GTLPlusDomainsPeopleFeed
2014-09-10 23:57:53.610 CalendarPanel[24383:60b] GTLPlusPerson (plus#person) registration conflicts with GTLPlusDomainsPerson
2014-09-10 23:57:53.610 CalendarPanel[24383:60b] GTLPlusPlace (plus#place) registration conflicts with GTLPlusDomainsPlace
2014-09-10 23:57:53.613 CalendarPanel[24383:60b] GTLStorageChannel (api#channel) registration conflicts with GTLDriveChannel
2014-09-10 23:57:53.986 CalendarPanel[24383:60b] Fetched number of calendars: (null)

我的两个问题是: 1. 我怎样才能摆脱这些冲突? 2. 我的代码看起来适合我想做的事情吗? (从用户那里获取所有日历)我认为使用这个 GData 类真的很棘手,那里的信息非常有限/或非常过时。

最佳答案

与其安装整个 Pod,不如尝试使用子 pods

pod 'Google-API-Client/Calendar', '~> 1.0'

或者任何你需要的

pod 'Google-API-Client/Drive', '~> 1.0'

关于ios - 尝试在 iOS 中获取 Google 日历时,控制台显示奇怪的 api#channel 冲突。怎么解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25775774/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com