I am using FCM with my ios push notification. How can I navigate to a specific navigation link when the user taps the push notification. Thank you in advance for your help!
I understand that I will handle the push notification tap on this function.
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// Print message ID.
if let messageID = userInfo[gcmMessageIDKey] {
print("Message ID userNotificationCenterdidReceive response: \(messageID)")
}
// Print full message.
print(userInfo)
let application = UIApplication.shared
if(application.applicationState == .active){
print("user tapped the notification bar when the app is in foreground")
}
if(application.applicationState == .inactive)
{
print("user tapped the notification bar when the app is in background")
}
completionHandler()
}
I also have an @EnvironmentObject
that controls which tabItem is active and which NavigationLink is open.
How can I access this EnvironmentObject on my UNNotificationResponse didReceive function?