func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
print("payload",payload.dictionaryPayload)
{
let state = UIApplication.shared.applicationState
if state == .background || state == .inactive{
startTimer()
}
}
func startTimer() {
timer2 = Timer.scheduledTimer(timeInterval: 7, target: self, selector: (#selector(updateTimer2)), userInfo: nil, repeats: true)
}
@objc func updateTimer2() {
seconds2 += 7
isPushNotificationCallReceived = true
let content = UNMutableNotificationContent()
content.title = self.message
content.body = self.callerName
content.badge = 0
content.sound = UNNotificationSound(named: "phone_loud.wav")
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: 0.1, repeats: false)
let request = UNNotificationRequest(identifier: "SimplifiedIOSNotification", content: content, trigger: trigger)
UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)]
print(seconds2)
if seconds2 == 28 {
isPushNotificationCallReceived = false
seconds2 = 0
timer2.invalidate()
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers:
["SimplifiedIOSNotification"])
UIApplication.shared.applicationIconBadgeNumber = 0
}
}