我可以在我的应用程序中抑制系统警报吗?

发布于 2024-10-09 23:18:04 字数 77 浏览 4 评论 0原文

当系统警报弹出时,我的应用程序是否可以“接管”?我的应用程序禁用了空闲计时器,但是当弹出系统警报时,警报似乎正在启用计时器。对此我能做什么?

Is it possible for my app to "take over" when a system alert pops up? My app disables the idle timer, but when a system alert pops up, the alert seems be enabling the timer. What can I do about that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷了相思 2024-10-16 23:18:04

您是否可以挂钩当您的应用程序进入和退出后台时调用的方法之一?你说,其中之一?

- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"applicationWillResignActive");
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"applicationDidEnterBackground");
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
}

我敢打赌,当这种情况发生时,其中一个会被叫到。当您的应用程序重新获得焦点时,您可以禁用空闲计时器。

编辑:在重新阅读问题时,看起来您正在寻求抑制警报(即不让它们发生)。呵呵,我主要关注你问题的后半部分。

Would it be possible for you to hook into one of the methods that gets called when your app goes in and out of the background? Say, one of these?

- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"applicationWillResignActive");
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
NSLog(@"applicationDidEnterBackground");
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
NSLog(@"applicationDidBecomeActive");
}

I bet one of those gets called when that happens. You can probably disable the idle timer when your app gets the focus back.

EDIT: On re-reading the question, it looks like you're looking to suppress the alerts (i.e., not let them happen). Heh, I focused on the latter half of your question.

冷︶言冷语的世界 2024-10-16 23:18:04

您是否试图抑制警报?那么答案是:你不能。

如果您试图防止警报干扰您的应用程序禁用空闲计时器,那么我相信 donkim 走在正确的道路上。

Are you trying to suppress the alerts? Then the answer is: you can't.

If you're trying to prevent the alerts from messing with your app's disabling of the idle timer, then I believe donkim is on the right trail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文