我有一个ios 11应用程序,它在给定的时间使用本地推送通知来通知剩余者。本地通知可以工作,当滑动时,它们会打开我的应用程序的主视图。我的应用程序的主视图是一个uitableviewcontroller。提醒是表视图中的行。
如果你点击一个提醒,它会打开一个新的视图控制器by self.presentview...新视图会在表视图上弹出。我没有使用序列图像板或xib文件,也不是通过编程来实现的。
如何将提醒id传递给推送通知并返回给应用程序,然后让提醒id打开第二个视图控制器?第二个视图控制器有更多关于提醒的详细信息。
发布于 2018-08-01 14:32:19
安排本地通知时,您可以在userInfo中设置所需的详细信息
let notification = UILocalNotification()
notification.fireDate = date
notification.alertBody = "Alert!"
notification.alertAction = "open"
notification.hasAction = true
notification.userInfo = ["reminderID": "222" ]您将获得didReceiveRemoteNotification格式的userInfo
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
print("didReceiveRemoteNotificationfetchCompletionHandler \(userInfo)")
/// HANDLE NAVIGATION HERE
}发布于 2018-08-03 13:30:57
基于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)
}
}如果你需要任何帮助,请告诉我
https://stackoverflow.com/questions/51626479
复制相似问题