当用户从fcm (Firebase消息传递)或调度程序本地通知(如下面的图像)得到通知时,我希望:
这里我的代码:
func onTest() {
let content = UNMutableNotificationContent()
content.title = "Weekly Staff Meeting"
content.body = "Every Tuesday at 2pm"
// Configure the recurring date.
var dateComponents = DateComponents()
dateComponents.calendar = Calendar.current
dateComponents.hour = 16 // 14:00 hours
dateComponents.minute = 11
// Create the trigger as a repeating event.
let trigger = UNCalendarNotificationTrigger(
dateMatching: dateComponents, repeats: true)
// Create the request
let uuidString = UUID().uuidString
let request = UNNotificationRequest(identifier: uuidString,
content: content, trigger: trigger)
// Schedule the request with the system.
let notificationCenter = UNUserNotificationCenter.current()
notificationCenter.add(request) { (error) in
if error != nil {
// Handle any errors.
}
}
}
现在,我的代码就像通常在5秒内消失的通知一样,我想让它像警报通知或Whatsapp调用通知一样。请帮忙谢谢。
发布于 2021-08-17 12:08:09
由于苹果的限制,app dev只能播放30秒的通知音。如果你的音调超过30秒,它将播放默认的通知音调。
如果您的通知音调在5秒后消失,请尝试将通知演示选项设置为列表、徽章和声音。一旦没有通知的横幅,30秒的音调就会一直播放到最后。
不幸的是,没有合法的方法或任何解决办法来连续通知铃声,如闹钟。希望我错了。
https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptions
发布于 2021-02-24 02:09:39
我认为,你可以做的是提交一个本地通知。但是,是的,这并不完全像苹果的警报通知。实际上,你没有这方面的许可。只能显示本地通知。
https://stackoverflow.com/questions/66347967
复制