I can successfully launch my app from Siri, but I get that NSUserActivity message in the debugger. I don't recall seeing that message in previous versions, but maybe I wasn't paying attention. What am I missing? Is there something I'm supposed to pop off of some stack? Set some flag?
(I can only launch the app on a device, not in the simulator, but that's a question for another day. Siri tells me something's wrong and to try again.)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType != "com.mydomain.myactivity" {
os_log("The app was called with an invalid activityType")
return false
}
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
let tabBarController = self.window!.rootViewController as! UITabBarController
tabBarController.tabBar.barTintColor = UIColor(red: 184.0/255.0, green: 64.0/255.0, blue: 37.0/255.0, alpha: 0.2)
guard let tabVCs = tabBarController.viewControllers else {
os_log("restorationHandler: Can't get tabVCs")
return false
}
guard let myTargetViewController = mainStoryboard.instantiateViewController(withIdentifier: "myTargetViewController") as? MyTargetViewController else {
os_log("restorationHandler: Can't get myTargetViewController from storyboard")
return false
}
guard let tab1NavViewController = tabVCs[0] as? UINavigationController else {
os_log("restorationHandler: Can't get tab1NavViewController from tabVCs")
return false
}
tabBarController.selectedIndex = 0
myTargetViewController.calledFromShortcut = true
tab1NavViewController.pushViewController(myTargetViewController, animated: true)
return true
}
Message is appear because you did not handle userActivity's interaction. Simple handler is shown below: