首页 > 解决方案 > 使用 iOS UNUserNotificationCenter,如何设置闹钟的开始和结束时间?

问题描述

使用 iOS UNUserNotificationCenter 我可以设置闹钟的开始和结束时间吗?

例如,我想每天早上 7:00 到晚上 10:00 设置闹钟,重复间隔为 30 分钟。

喜欢这个应用程序。

在此处输入图像描述

我的代码如下。

UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [id.uuidString])
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(repeatTypeFromNow * 60), repeats:true)
let  request = UNNotificationRequest(identifier: id.uuidString, content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)

是否可以在无服务器环境中使用?

标签: iosswift

解决方案


推荐阅读