简体   繁体   English

如何在一个信号iOS Swift中处理可点击推送通知

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

I already get the data from one signal (additional Data). 我已经从一个信号(附加数据)中获取数据。 But I want to present view controller by clicking the push notification itself. 但我想通过单击推送通知本身来呈现视图控制器。 Can someone help me. 有人能帮我吗。 Thanks in advance. 提前致谢。

Did you check OneSignal's docs on Deep Linking? 您是否查看过OneSignal关于Deep Linking的文档? https://documentation.onesignal.com/docs/links https://documentation.onesignal.com/docs/links

There is a demo project on Github that might help you: https://github.com/OneSignal/OneSignal-iOS-SDK/tree/master/Examples Github上有一个可能对你有帮助的演示项目: https//github.com/OneSignal/OneSignal-iOS-SDK/tree/master/Examples

add this in your didFinishLaunchingWithOptions this code will check that if app was launched using appIcon or tapping on notification 在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