I am trying to have an iPhone vibrate multiple consecutive times in the Notification Center. While researching on this, I found several posts saying Apple only allows a single alert to be fired and therefore only one vibration per alert.
I recently saw a WhatsApp call coming in on my phone and the thing just went crazy. I try to achieve the same behavior. One possible solution would be to just delete and create notifications over and over again, but I am pretty sure Apple will just decline this behavior.
This is how this could look like:
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)
So, what's the best way to achieve this and comply with Apples guidelines?
Does not seem possible. From 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.
I'd imagine Apple allows some popular apps to achieve this though, like WhatsApp, YouTube, etc...