简体   繁体   English

检测iOS上的传入NotificationCenter通知

[英]Detect incoming NotificationCenter notification on iOS

Is there an API that allows me to know when NotificationCenter will pop a notification on the top of the screen while my app is running (for example for an incoming Message or email)? 是否有API可以让我知道NotificationCenter何时会在我的应用程序运行时在屏幕顶部弹出通知(例如传入的消息或电子邮件)?

It causes a big performance glitch to my game so I'd like to pause it and unpause once the notification has disappeared. 它会给我的游戏带来巨大的性能故障,所以我想暂停它并在通知消失后取消暂停。 If there is no event to listen to I can only think of monitoring FPS and pausing for a few seconds if it drops below a threshold. 如果没有可以收听的事件,我只能考虑监视FPS并暂停几秒钟,如果它低于阈值。 Any other suggestions? 还有其他建议吗?

EDIT: My answer is only for popup notifications, not for the ones that scroll on to the top of the screen. 编辑:我的答案仅适用于弹出通知,而不适用于滚动到屏幕顶部的通知。 Sorry :( 对不起:(


In your app delegate, the method 在您的app delegate中,该方法

- (void)applicationWillResignActive:(UIApplication *)application

will be called. 将被召唤。

And then 接着

- (void)applicationDidBecomeActive:(UIApplication *)application

when it's time to start up again. 什么时候重新开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM