I receive a notification in App Delegate with a question in the data (userInfo variable), and I need this String to be passed to the View Controller named "Question". I want this String to be shown in this variable @IBOutlet weak var question: UILabel! which is in the Question View Controller.
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: \(messageID)")
}
// Print full message.
print(userInfo)
let storyboard = UIStoryboard(name:"Main", bundle:nil)
let question_view = storyboard.instantiateViewController(withIdentifier: "Question")
window?.rootViewController = question_view
completionHandler()
}
How can I pass the data to the View Controller? I've tried to access the variable from there but I didn't work. Thanks!