我正在創建一個EKEvent
,其代碼爲EKAlarm
,如下面的代碼所示。在大多數情況下,這是完美的。EKEvent不保存EKAlarm,但僅在某些設備上沒有錯誤
但是,在數量有限的設備上,警報沒有設置。該事件在日曆中創建,但報警丟失。
EKEvent* event = [EKEvent eventWithEventStore:eventStore];
event.title = @"Event Title";
event.allDay = YES;
event.notes = @"Event Notes";
event.calendar = calendar ? calendar : eventStore.defaultCalendarForNewEvents;
event.startDate = date;
event.endDate = date;
EKAlarm *alarm = [EKAlarm alarmWithAbsoluteDate:reminderDate];
[event addAlarm:alarm];
NSError* error = nil;
BOOL success = [eventStore saveEvent:event span:EKSpanThisEvent commit:TRUE error:&error];
此時,成功爲YES,錯誤爲零。此外,事件對象還有一個包含警報對象的警報數組。如果我嘗試刪除該鬧鐘並保存該事件(應用程序崩潰,因爲鬧鐘實際上不存在),則這會成爲問題。
我無法確定受影響設備的獨特性。它發生每當以下設備:
- iPhone 6與iOS 8.1.1
- iPhone 6與iOS 8.4
- iPhone 5與iOS 8.4
而下面沒有該問題:
- iPhone 6與iOS 8.4
- iPhone 6與iOS 8。 3
- iPhone 6與iOS 8.0.2
- iPhone模擬器與iOS 8.1 &的iOS 8.4
- iPhone 5與iOS 9
所有上述設備都不同的物理設備。所以它似乎沒有任何特定的設備型號或iOS版本。
我也嘗試過不同的日曆,包括本地日曆和同步(例如Exchange,Google)日曆。在受影響的設備上,問題發生在所有日曆上。
我也嘗試設置/未設置時區覆蓋和默認警報時間(設置>郵件,聯繫人,日曆)。
有沒有人遇到過這個問題?
UPDATE:
我建立了一個測試應用程序的問題,從其他任何可能的原始應用程序內部正在進行隔離。它在大多數設備上都能正常工作,但受影響的設備上仍然存在此問題。
以下是EKEvent對象在[eventStore saveEvent:event span:EKSpanThisEvent commit:TRUE error:&error]
之後的樣子。請注意,此通話返回YES並且error
爲零。
EKEvent Object: EKEvent <0x1742e1e00>
{
EKEvent <0x1742e1e00>
{ title = Event Title;
location = ;
calendar = EKCalendar <0x1740ab4c0> {title = Calendar; type = Exchange; allowsModify = YES; color = #CC73E1;};
alarms = (
"EKAlarm <0x170085190> {triggerDate = 2015-09-02 23:21:53 +0000}"
);
URL = (null);
lastModified = 2015-08-25 23:21:53 +0000;
startTimeZone = (null);
startTimeZone = (null)
};
location = ;
structuredLocation = (null);
startDate = 2015-09-04 14:00:00 +0000;
endDate = 2015-09-05 13:59:59 +0000;
allDay = 1;
floating = 1;
recurrence = (null);
attendees = (null);
travelTime = (null);
startLocation = (null);
};
然後我打電話[eventStore reset]
,它看起來像這樣:
EKEvent Object: EKEvent <0x1702e2600>
{
EKEvent <0x1702e2600>
{ title = Event Title;
location = ;
calendar = EKCalendar <0x1740ad200> {title = Calendar; type = Exchange; allowsModify = YES; color = #CC73E1;};
alarms = (null);
URL = (null);
lastModified = 2015-08-25 23:21:53 +0000;
startTimeZone = (null);
startTimeZone = (null)
};
location = ;
structuredLocation = (null);
startDate = 2015-09-04 14:00:00 +0000;
endDate = 2015-09-05 13:59:59 +0000;
allDay = 1;
floating = 1;
recurrence = (null);
attendees = (null);
travelTime = (null);
startLocation = (null);
};
更新#2
我做了一些更多的測試,並已能夠重現問題始終在Exchange同步日曆上。之前我曾排除過這種情況,因爲我曾要求客戶嘗試選擇非Exchange日曆,並且他們報告問題仍然存在。