应用程序可以在通知中心中同时使用提醒和横幅吗? [英] Can an app use both alerts and banners in Notification Center?

查看:294
本文介绍了应用程序可以在通知中心中同时使用提醒和横幅吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Mac OS X应用程序以使用通知中心。

I am creating a Mac OS X application to use Notification Center. Some notifications should remain on the screen until the user interacts with them, and others should disappear shortly after displaying.

NSUserNotificationAlertStyle

The NSUserNotificationAlertStyle key and changing System Preferences allow changing between banners and alerts. However, both approaches change all the notifications sent from my application.

我可以发送一些通知作为警报,其他人作为横幅?如果是,如何?

Can I send some notifications as alerts and others as banners? If so, how?

推荐答案

NSUSerNotificationAlertStyle 可以设置应用程序的默认通知样式,并设置该应用程序的全部通知的样式。

NSUSerNotificationAlertStyle is the only way the developer can set the default notification style for the application, and it sets the style for all notifications from that app.

如果你认为有两种不同类型的通知是非常重要的,你可以通过使用一个隐藏的辅助应用程序使用不同的主要应用程序NSUserNotificationAlertStyle来解决这个问题。

If you think it's really important for you to have 2 different kinds of notifications you can work around the problem by having a hidden helper application with a different NSUserNotificationAlertStyle than the main app.

请记住,虽然您设置了默认通知样式,但用户可以随时在通知中心prefs中更改,使您的帮助应用程序无用。

Remember though you set the default notification style, but the user can change it whenever he wants in the notification center prefs, making your helper app useless.

这篇关于应用程序可以在通知中心中同时使用提醒和横幅吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆