簡體   English   中英

如何在一個信號iOS Swift中處理可點擊推送通知

[英]How to Handle Clickable Push Notification In One Signal iOS Swift

我已經從一個信號(附加數據)中獲取數據。 但我想通過單擊推送通知本身來呈現視圖控制器。 有人能幫我嗎。 提前致謝。

您是否查看過OneSignal關於Deep Linking的文檔? https://documentation.onesignal.com/docs/links

Github上有一個可能對你有幫助的演示項目: https//github.com/OneSignal/OneSignal-iOS-SDK/tree/master/Examples

在didFinishLaunchingWithOptions中添加此代碼,此代碼將檢查是否使用appIcon啟動應用程序或點擊通知

 self.window = UIWindow(frame: UIScreen.main.bounds)
        let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let tabBar = storyBoard.instantiateViewController(withIdentifier: "MainNavigationController")
                as? UINavigationController


            self.window?.rootViewController = tabBar
            self.window?.makeKeyAndVisible()
if let notification = launchOptions?[.remoteNotification] as? [String: AnyObject] {
            // 2
            let aps = notification["aps"] as! [String: AnyObject]
            let vc = storyBoard.instantiateViewController(withIdentifier: "EmergencyRequestViewController") as? EmergencyRequestViewController
            tabBar?.pushViewController(vc!, animated: true)
            }
        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM