App Delegateでデータ内の質問(userInfo変数)で通知を受け取り、この文字列をView Controllerに渡す必要があります。この文字列をこの変数に表示します。@IBOutlet弱い質問:UILabel!は質問表示コントローラにあります。Swiftで通知コントローラに通知データを渡す方法
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()
}
どのようにデータをView Controllerに渡すことができますか?私はそこから変数にアクセスしようとしましたが、うまくいきませんでした。ありがとう!
[View Controller間でデータを受け渡しする]の可能な複製(http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers) – thewaywewere