我完全复用了官方wwdc的Alarmkit的demo。测试过程发现12,13pro闹钟完全正常,15pro和16pro闹铃时间不对,经常不响,而且在设置中切换市时区时会立马响。这是api的bug么
Alarmkit
Thank you for your post. Could you please provide the version of iOS you are using for your test? Additionally, could you provide a sample and a method for me to reproduce the issue you are experiencing?
Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.
Albert Pascual Worldwide Developer Relations.
func createFixAlarm(_ ck: CKRecord, _ cdate: Date, _ block: ((Bool, String?)->Void)? = nil) async { if cdate <= Date() { JCTips.showTip("闹钟时间不可小于当前时间!") block?(false, nil) return } let keynoteDateComponents = DateComponents( calendar: .current, year: cdate.year, month: cdate.month, day: cdate.day, hour: cdate.getOnComponent(.hour), minute: cdate.getOnComponent(.minute)) let date = Calendar.current.date(from: keynoteDateComponents)! typealias AlarmConfiguration = AlarmManager.AlarmConfiguration<JCMeta>
let stopButton = AlarmButton(
text: "我知道了",
textColor: .white,
systemImageName: "stop.circle")
let alertPresentation = AlarmPresentation.Alert(
title: LocalizedStringResource(stringLiteral: ck[RecordData.title.rawValue] as? String ?? "快开始了!"),
stopButton: stopButton,
)
let attributes = AlarmAttributes<JCMeta>(
presentation: AlarmPresentation(
alert: alertPresentation),
metadata: JCMeta(),
tintColor: Color.accent)
let su = ck[RecordData.sound.rawValue] as? String
let alarmConfiguration = AlarmConfiguration(
schedule:.fixed(date),
attributes: attributes,stopIntent: StopAlarmIntent(),
sound: su == nil ? .default : .named(su!)
)
let id = UUID()
do {
let alarm = try await AlarmManager.shared.schedule(id: id, configuration: alarmConfiguration)
}catch {
}
}