I noticed a strange issue when I registered several local push notifications:
for model in myModelArray
{
let calendar = Calendar.current
let scheduleDate = calendar.date(byAdding: .second, value: i * 5, to: Date())!
let notification = UILocalNotification()
notification.fireDate = scheduleDate
notification.alertBody = "My push notification title"
UIApplication.shared.scheduleLocalNotification(notification)
i += 1
}
When my local push notifications appear in background mode, I tap on it and want to present one screen directly:
func application(_ application: UIApplication, didReceive notification: UILocalNotification)
{
let mainMenuVC = self.window?.rootViewController as! MenuViewController
let navController = mainMenuVC.sideMenuController?.rootViewController as! UINavigationController
let myDestinationVC = navController.storyboard?.instantiateViewController(withIdentifier: "MyIdentifier") as! MyDestinationViewController
navController.pushViewController(mydestinationVC, animated: false)
}
But it takes up to one minute for the transition between my menuVC and my destinationVC to happen. When my app is opened, pushing the view controller works perfectly. Did I forget about something? What is wrong with my code? The delay only happens when the app is closed and reopens again after tapping on the push notification.