【问题标题】:iOS unable to update calendar event when synced to exchange account同步到交换帐户时,iOS 无法更新日历事件
【发布时间】:2016-03-28 13:50:14
【问题描述】:

我在使用 Exchange 电子邮件帐户更新 ipad 上的日历活动时遇到问题。它将创建新事件没问题,但在更新时,它将创建另一个事件,而不是更新现有事件。几件事

  • 以下代码适用于任何其他类型的电子邮件帐户(例如 gmail)
  • 如果我没有电子邮件,下面的代码可以工作(所以它只是写入本地日历)
  • 是的,我已检查我的交换电子邮件是否启用了日历

抛出的错误是:

Error getting event with identifier 9E678016-F8E4-46B1-9043-E54E09A148F0:5A89FFAF15B1408386A9CBD518BBDD770: Error Domain=EKCADErrorDomain Code=1010

这是我正在使用的代码。

 [self.eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
    if (granted) {
        dispatch_sync(dispatch_get_main_queue(), ^{
            NSString *appleEventId = [item valueForKey:@"appleEventId"];
            EKEvent *currentEvent = [self.eventStore eventWithIdentifier:[item valueForKey:@"appleEventId"]];
            if (currentEvent){
                NSLog(@"LOG101: found an event with %@",appleEventId );
                [self createEvent:currentEvent inEventStore:self.eventStore forActivity:item];
            }
            else{
                NSLog(@"LOG101: COULD NOT FIND an event with %@",appleEventId );
                EKEvent *event = [EKEvent eventWithEventStore:self.eventStore];
                [self createEvent:event inEventStore:self.eventStore forActivity:item];
            }
            completionHandler(YES);
        });
    }
    else{
        dispatch_sync(dispatch_get_main_queue(), ^{
        completionHandler(NO);
        });
    }
}];

(创建事件做了一堆客户逻辑,但最终调用以下创建事件)

  [eventStore saveEvent:event span:EKSpanThisEvent error:&err];

这令人沮丧,因为该代码适用于除交换之外的所有其他内容。任何提示/建议都会很棒。谢谢

【问题讨论】:

  • 更新:似乎当我创建一个新事件并将其添加到我的交换日历时,它在同步到服务器后不久修改了事件标识符。还有其他人有这个问题吗? (我觉得它不能只是我......)

标签: ios email calendar duplicates exchange-server


【解决方案1】:

我已经为类似的问题烦恼了两天!

eventIdentifier 的文档说明:

“如果事件的日历发生变化,它的标识符很可能也会发生变化。” https://developer.apple.com/reference/eventkit/ekevent/1507437-eventidentifier?language=objc

还有 calendarIdentifier 的文档说明:

“与日历的完全同步将丢失此标识符。您应该制定一个计划,通过缓存其其他属性来处理其标识符不再可获取的日历。” https://developer.apple.com/reference/eventkit/ekcalendar/1507380-calendaridentifier?language=objc

我认为可以肯定地说,如果日历已同步,您不能依赖在本地保存日历或事件标识符以供以后使用:-(

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-12
    • 2022-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多