ios - 从 ios 将事件添加到谷歌日历
<p><p>我已按照以下教程从谷歌日历中获取事件,这工作正常。
<a href="https://developers.google.com/google-apps/calendar/quickstart/ios" rel="noreferrer noopener nofollow">https://developers.google.com/google-apps/calendar/quickstart/ios</a> </p>
<p>现在我被困在我的 iOS 应用程序的插入事件中,因此它也可以与网络同步。请指导我正确的方向或发布一些示例代码。</p>
<p>我在 viewDidLoad 中使用此代码进行授权</p>
<pre><code>// Initialize the Google Calendar API service & load existing credentials from the keychain if available.
self.service = [ init];
self.service.authorizer =
[GTMOAuth2ViewControllerTouch authForGoogleFromKeychainForName:kKeychainItemName
clientID:kClientID
clientSecret:kClientSecret];
</code></pre>
<p>授权似乎很好,因为 fetch 事件工作得很好。但我正在使用以下代码添加事件</p>
<pre><code>- (void)addAnEvent {
// Make a new event, and show it to the user to edit
GTLCalendarEvent *newEvent = ;
newEvent.summary = @"Sample Added Event";
newEvent.descriptionProperty = @"Description of sample added event";
// We'll set the start time to now, and the end time to an hour from now,
// with a reminder 10 minutes before
NSDate *anHourFromNow = ;
GTLDateTime *startDateTime =
timeZone:];
GTLDateTime *endDateTime = [GTLDateTime dateTimeWithDate:anHourFromNow
timeZone:];
newEvent.start = ;
newEvent.start.dateTime = startDateTime;
newEvent.end = ;
newEvent.end.dateTime = endDateTime;
GTLCalendarEventReminder *reminder = ;
reminder.minutes = ;
reminder.method = @"email";
newEvent.reminders = ;
newEvent.reminders.overrides = ;
newEvent.reminders.useDefault = ;
;
}
- (void)addEvent:(GTLCalendarEvent *)event {
GTLQueryCalendar *query = [GTLQueryCalendar queryForEventsInsertWithObject:event
calendarId:@"primary"];
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayAddEventResultWithTicket:finishedWithObject:error:)];
}
- (void)displayAddEventResultWithTicket:(GTLServiceTicket *)ticket
finishedWithObject:(GTLCalendarEvents *)events
error:(NSError *)error {
if (error == nil) {
NSLog(@"I think event has been added successfully!");
} else {
NSLog(@"ERROR : %@", error.localizedDescription);
}
}
</code></pre>
<p>但我收到错误响应“无法完成操作。(权限不足)”</p>
<p>谢谢,</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>要将事件添加到日历,请使用以下方法</p>
<pre><code>
</code></pre>
<p>另请注意,您必须使用范围 kGTLAuthScopeCalendar 进行授权才能具有读/写访问权限。</p></p>
<p style="font-size: 20px;">关于ios - 从 ios 将事件添加到谷歌日历,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/31176308/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/31176308/
</a>
</p>
页:
[1]