OGeek|极客世界-中国程序员成长平台

标题: ios - 在用户点击它们之前在后台处理通知 - Swift 3 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:51
标题: ios - 在用户点击它们之前在后台处理通知 - Swift 3

在 swift 3 中,如何在应用处于后台且用户点击通知之前处理本地通知?

UserNotificationController.userNotificationCenter(_:willPresent:withCompletionHandler 仅在用户点击通知时调用。

我的目标是创建一个本地通知,该通知显示一个类似于来电的屏幕,用户可以在其中滑动以接听或挂断电话。

谢谢!



Best Answer-推荐答案


根据这个 SO question,这根本不可能:

iOS Local Notification - Callback when in Background

引用该链接中给出的部分答案:

If your app was in the background or not running, and the user does not tap the notification and summon your app, you will get nothing at all and will have no way to know that the notification fired. This is because notifications are not for your benefit but are a way of sending a message to the user. (It sounds, from your question, as if you may be misusing local notifications as a way of sending a message to yourself. That is not what they are for.)

关于ios - 在用户点击它们之前在后台处理通知 - Swift 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44475481/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4