显然,现在ios10可以实现:optional func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: (UNNotificationPresentationOptions) -> Void)这个答案基本上说完成此任务所需的工具:当您的应用处于打开状态且在前台时,显示股票iOS通知横幅吗?我只是不太了解如何将所有内容放在一起。我不知道这有多重要,但是我无法保留可选的func,而xcode希望我将其切换为私有。我正在尝试显示徽章,并且文档提供了static var badge: UNNotificationPresentationOptions { get }有点丢在这里。然后,我假设是否要从获取这些徽章中排除某个视图控制器,并且我没有使用导航控制器,那么我发现的这段代码行得通吗?:var window:UIWindow?if let viewControllers = window?.rootViewController?.childViewControllers {for viewController in viewControllers { if viewController.isKindOfClass(MyViewControllerClass) { print("Found it!!!") } }}
3 回答
![?](http://img1.sycdn.imooc.com/533e4c9c0001975102200220-100-100.jpg)
跃然一笑
TA贡献1826条经验 获得超6个赞
还可以设置在应用程序处于前台时显示通知的关键:
content.setValue(true, forKey: "shouldAlwaysAlertWhileAppIsForeground")
在你的UNNotificationRequest。至于其他内容,请参见Rajan Maheshwari的出色回答。
没有找到匹配的内容?试试慕课网站内搜索吧
- 3 回答
- 0 关注
- 1127 浏览
添加回答
举报
0/150
提交
取消