让 iPhone 在锁定时振动多次的最佳方法是什么?
What's the best way to let an iPhone vibrate multiple times when locked?
我正在尝试让 iPhone 在通知中心连续振动多次。
在对此进行研究时,我发现有几篇帖子说 Apple 只允许发出一个警报,因此每次警报只允许一次振动。
我最近看到我的 phone 打来了一个 WhatsApp 电话,事情变得很疯狂。我尝试实现相同的行为。
一种可能的解决方案是一遍又一遍地删除和创建通知,但我很确定 Apple 会拒绝这种行为。
这可能是这样的:
var interval = 10
var i = 0
while(i < interval) {
sendNotification(message)
sleep(1)
UIApplication.sharedApplication().cancelAllLocalNotifications()
i += 1
}
sendNotification(message)
func sendNotification(text: String) {
let notification = UILocalNotification()
notification.alertBody = "This is a test"
notification.alertAction = "Stop Alarm"
notification.soundName = UILocalNotificationDefaultSoundName
notification.category = "ALERT"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
那么,实现这一目标并遵守 Apple 指南的最佳方式是什么?
似乎不可能。来自 iOS Human Interface Guidelines - Notifications:
Note that you can’t programmatically cause the device to vibrate when
a notification is delivered, because the user has control over whether
alerts are accompanied by vibration.
我想 Apple 允许 一些 流行的应用程序来实现这一点,比如 WhatsApp、YouTube 等...
我正在尝试让 iPhone 在通知中心连续振动多次。 在对此进行研究时,我发现有几篇帖子说 Apple 只允许发出一个警报,因此每次警报只允许一次振动。
我最近看到我的 phone 打来了一个 WhatsApp 电话,事情变得很疯狂。我尝试实现相同的行为。 一种可能的解决方案是一遍又一遍地删除和创建通知,但我很确定 Apple 会拒绝这种行为。
这可能是这样的:
var interval = 10
var i = 0
while(i < interval) {
sendNotification(message)
sleep(1)
UIApplication.sharedApplication().cancelAllLocalNotifications()
i += 1
}
sendNotification(message)
func sendNotification(text: String) {
let notification = UILocalNotification()
notification.alertBody = "This is a test"
notification.alertAction = "Stop Alarm"
notification.soundName = UILocalNotificationDefaultSoundName
notification.category = "ALERT"
UIApplication.sharedApplication().scheduleLocalNotification(notification)
那么,实现这一目标并遵守 Apple 指南的最佳方式是什么?
似乎不可能。来自 iOS Human Interface Guidelines - Notifications:
Note that you can’t programmatically cause the device to vibrate when a notification is delivered, because the user has control over whether alerts are accompanied by vibration.
我想 Apple 允许 一些 流行的应用程序来实现这一点,比如 WhatsApp、YouTube 等...