I have an app that receive push notifications. When I press the notification, I want to navigate to first index of my UITabBarController , it has to do it when the app is opened or not. My base index is the second one , I mean , index = 1 and the first index is 0 that is my view controller goal. I already tested some code in AppDelegate but it doesn't work. I`m using OneSignal Service, Any ideas ? thanks.
This code is in didFinishLaunchingWithOptions function
let notificationOption = launchOptions?[.remoteNotification]
if let notification = notificationOption as? [AnyHashable : Any]{
print(notification)
(window?.rootViewController as? UITabBarController)?.selectedIndex = 0
}
and this code is in didReceiveRemoteNotification function
print(userInfo)
(window?.rootViewController as? UITabBarController)?.selectedIndex = 0