我的應用程式中有許多螢屏。因此,當用戶點擊本地通知時,我想與其中一個螢屏進行深度鏈接。
其中一個螢屏上可能沒有運行或處于活動狀態,或者處于非活動或暫停狀態。
我看不出如何做到這一點
。如果有誰能解釋一下,那就太好了
uj5u.com熱心網友回復:
你可以使用DeepLinkKit來導航到不同螢屏。我在我的應用程式中使用了這個庫,我在應用程式的每個螢屏上都有大約30-37個深度鏈接。我將其與Cordinators模式一起用于導航。如果你在實施方面需要任何幫助,請告訴我。
uj5u.com熱心網友回復:
從任何地方發送通知。
func sendNotification() { let info: [String: String] = ["vc_name"/span>: "CartViewController"] 。 NotificationCenter.default.post(name。Notification.Name("YourLocalNotification"/span>), object: nil, userInfo: info) }在你的根控制器中添加關于接收通知的通知處理程式
。override func viewDidLoad() { super.viewDidLoad() NotificationCenter.default.addObserver(self, selector: #selector(self.youNotificationAction(notification:)), name: Notification.Name("YourLocalNotification"/span>), object: nil) }
接收通知,檢查你的通知資訊,并導航到你各自的控制器。
@objc func youNotificationAction(notification: Notification) {
if let vcName = notification. userInfo?["vc_name"] as? String {
let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let toVC = storyBoard.instantiateViewController(withIdentifier: vcName)
navigationController?.pushViewController(toVC, animated: true)。
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/321925.html
標籤:
上一篇:具體的JSON決議問題--不同物件的陣列--Swift
下一篇:SQL。如何用計數來劃分列?
