gpt4 book ai didi

ios - 从 iOS 11 中的本地通知打开 View Controller

转载 作者:行者123 更新时间:2023-11-30 11:17:19 26 4
gpt4 key购买 nike

我有一个 ios 11 应用程序,它在给定时间使用本地推送通知来获取剩余内容。本地通知有效,当滑动时,它们会打开我的应用程序的主视图。我的应用程序的主视图是 uitableviewcontroller。提醒是表格 View 中的行。

如果您单击提醒,它会通过 self.presentview 打开一个新的 View Controller ...新 View 会在 TableView 上弹出。我没有使用 Storyboard 或 xib 文件并以编程方式执行此操作。

如何将提醒 ID 传递到推送通知并返回到应用程序,然后让该提醒 ID 打开第二个 View Controller ?第二个 View Controller 具有有关提醒的更多详细信息。

最佳答案

基于 anuraj 的回答。在userInfo中设置所需的详细信息

然后使用以下方法处理导航(在 appDelegate.swift 中)

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {

print("didReceiveRemoteNotificationfetchCompletionHandler \(userInfo)")
let id = userInfo["reminderID"] as! String
/// HANDLE NAVIGATION HERE
if let tableVC = self.window?.rootViewController as? yourTableViewControllerClass {
let reminderDetailsVC = yourReminderDetailsVC()
reminderDetailsVC.reminderID = id
tableVC.present(reminderDetailsVC, animated: true)
}


}

如果您需要任何帮助,请告诉我

关于ios - 从 iOS 11 中的本地通知打开 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51626479/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com