I use Notification Service Extension to vibrate device two time, background mode is on, below method is working on iOS 11
& 12.0.1
but not working in iOS 12.1
background modes are below:
here is the code :
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
DispatchQueue.main.asyncAfter(deadline: .now() + 1.4) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
contentHandler(bestAttemptContent)
}
}