iOS 中自动暂停本地通知
我正在开发一个应用程序,如果用户没有对之前显示的通知采取任何操作(既不关闭通知,也不打开应用程序),我希望自动将收到的通知暂停 10 分钟。这在iOS中是必需的
I am developing an application in which I want to snooze the received notification automatically for 10 mins, if user didn't take any action (neither dismiss notification, nor opened the app) on the previously displayed notification. This is required in iOS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你不能那样做。您见过应用程序有这样的行为吗?不,因为这是不可能的(而且不连贯)。
这样想吧。如果用户什么都不做,您的应用程序就不会收到通知已触发的信号。所以它不能“做”任何回应。你无法对没有发生的事情做出反应。
这是另一种看待它的方式。当通知触发时,您的应用程序甚至可能没有运行。如果用户什么都不做,您的应用仍然将不会运行。那么它怎么能“做”任何事情呢?
在评论中,您引用了一个具有“自动休眠”功能的应用程序。但该应用程序可能不会因为用户没有执行任何操作而暂停。它提前安排一个重复通知(或多个通知),因此当用户什么都不做时,重复已经出现。当用户做出响应时,应用删除额外的预定通知。所以你看,正如我之前所说,应用程序响应用户做过的事情,而不是用户没有做的事情(尽管我可以明白为什么会这样)行为可能会给人一种错觉,即它按照您的要求进行操作)。
You can't do that. Have you ever seen an app behave that way? No, because it's impossible (and incoherent).
Think of it this way. If the user does nothing, your app gets no signal that the notification fired. So it cannot "do" anything in response. You cannot respond to something that didn't happen.
Here's another way to look at it. When the notification fires, your app might not even be running. If the user does nothing, your app still won't be running. So how can it "do" anything?
In a comment, you referenced an app that has an "autosnooze" feature. But that app likely isn't snoozing in response to the fact that the user didn't do anything. It is scheduling a repeating notification (or multiple notifications) in advance, so the repetitions are already present when the user does nothing. When the user does respond, the app deletes the extra scheduled notifications. So you see, as I said before, the app responds to something that the user did do, not to something the user didn't do (though I can see why this behavior might give the illusion that it does what you asked to do).