gpt4 book ai didi

ios - OneSignal 按推送通知去 View Controller iOS Swift

转载 作者:可可西里 更新时间:2023-11-01 02:18:08 24 4
gpt4 key购买 nike

我想在按下推送通知后导航到特定的 View Controller ,如何使用 OneSignal 推送通知在此处执行此操作?

 _ = OneSignal(launchOptions: launchOptions, appId: "b2f7f966-d8cc-11e4-bed1-df8f05be55ba") { (message, additionalData, isActive) in
NSLog("OneSignal Notification opened:\nMessage: %@", message)

if additionalData != nil {
NSLog("additionalData: %@", additionalData)
// Check for and read any custom values you added to the notification
// This done with the "Additonal Data" section the dashbaord.
// OR setting the 'data' field on our REST API.
if let customKey = additionalData["newid"] as! Int {
//The navigation to a view controller code should be goes here...
//I've no idea how to do it, I've tried some ways from stackoverflow also didn't work for me
}
}
}

最佳答案

您可以使用 jkasten 建议的转场,或者:

let controller = self.storyboard!.instantiateViewControllerWithIdentifier("storyboardID") as! ClassOfYourView
self.presentViewController(controller, animated: true, completion: nil)

无论哪种方式,您仍然需要创建一个 Storyboard ID。

关于ios - OneSignal 按推送通知去 View Controller iOS Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34646715/

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