问题标签 [nsusernotification]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
775 浏览

macos - NSUserNotification 自定义声音(OS X,沙盒应用)

我想为通知中心使用自定义声音,但找不到太多关于此的文档。我知道如何为通知分配声音,也知道如何将新声音文件复制到 ~/Library/Sounds 然后使用这些新声音。我的应用程序是沙盒的,所以我当然必须要求用户确认他们想要安装新的声音,但我担心 App Store 会根据这条 App Store 规则拒绝:

2.15 应用必须是独立的、单一的应用安装包,并且不能在共享位置安装代码或资源

无论如何,是否可以在不将资源复制到 ~/Library/Sounds 的情况下使用带有 NSUserNotification 的自定义声音?

似乎在 iOS 上有这方面的文档,但在 OS X上没有。

提前致谢。

0 投票
0 回答
572 浏览

c++ - Qt 中的 MAC OS X 用户通知

我已经在 qt 中使用 NSUserNotification 和 NSUserNotificationCenter 实现了 UserNotificationAlert。我已经编写了在单击 actionButton 时执行操作的代码,但不幸的是它没有被执行。我有以下代码。

XYZ.h

XYZ.mm

代表.mm

主文件

显示 userNotification 但是当我单击“是”按钮时没有任何操作。我想我缺少将委托与主要功能联系起来,但我不知道该怎么做。请帮我解决这个问题。

0 投票
1 回答
418 浏览

objective-c - Handling Click Events with NSUserNotification Sent from CLI App

I have created an OSX command line application in Objective C and it now fires sidebar notification events like so:

I even used this technique to make it use another application's icon instead of a black terminal icon.

The trouble now, however, is that when you click the item, it launches the command line application instead of the application that I desire. How can I make the click on the sidebar notification launch my separate GUI application?

EDIT: Perhaps I need to use AppleScript to tell my CLI application to call my GUI application and instruct it to send a notification? That way, the event delegate is set to the GUI application, not the CLI application. If that's the case, I don't know how to make AppleScript launch and pass a message to my GUI application, nor how the GUI application can read that message.

0 投票
1 回答
312 浏览

swift - OS X 中的 NSUserNotification() onclick

如何使通知可点击?

我希望当用户单击 Mac 上的通知时,Safari 会打开指定的链接。

0 投票
2 回答
880 浏览

objective-c - 检测其他按钮点击(NSUserNotification)

我在互联网上搜索过,但找到的唯一方法是循环

如图所示:https ://stackoverflow.com/a/21365269/1795083

但是,我的应用有时会在很短的时间间隔内显示多个通知,因此这不是很有效也不是很有效。当按下垃圾桶按钮时,邮件应用程序如何处理它。必须至少有一个私有方法被调用。有人遇到过吗?提前致谢

0 投票
1 回答
923 浏览

objective-c - ObjectiveC - 如何使用 NSUserNotification 标识符属性

根据苹果文档https://developer.apple.com/reference/foundation/nsusernotification/1416410-identifier

NSUserNotification 有一个名为 identifier 的属性,它假设当标识符与另一个通知相同时替换通知。

但是,当我测试此功能时,通知似乎并没有真正被替换,只是没有发送。

如何实现通知中心仅存在一种通知但最新调用的通知更新到顶部的效果?

延迟 1 分钟发送通知 A + 通知 B + 通知 A

这是在 mac 通知中心显示的内容

无标识符

带标识符

请注意,由于存在标识符,如何未调用通知 A(第二次)

想要的效果

在这种情况下,通知 A 再次发送,之前的通知 A 消失了

0 投票
0 回答
330 浏览

swift - 使多个 NSUserNotifications(及其操作)按钮执行单独的操作

我一直在按照自己的节奏学习 Swift,在学习了如何制作 NSUserNotifications 之后,我已经深入研究了通知按钮,并让它们做事。

我知道如何使用 AppDelegate.swift 中的以下内容使单个通知的操作按钮执行操作

问题是,我如何让第二个做同样的事情?在我问这个问题之前,我已经在 SO、reddit 和众多 Swift 教程网站上搜索了一个易于理解的答案,因为在 C# 中委托和覆盖对我来说没有问题,我得到了概念,我完全不知道 Swift 如何做到这一点。

思考过程

因为didActivateNotification notification: NSUserNotification" inAppDelegate.swift包含标识符 "notification",如果我再次声明,它也是我的 ViewController 类中我的第一个 NSUserNotification 对象的标识符userNotificationCenter(),并将 "didActivateNotification 通知:NSUserNotification" 更改为 "didActivateNotification 通知:NSUserNotification",用于我的第二个 NSUserNotification具有标识符“notif”的对象,它应该为我的第二个通知的操作按钮执行相关操作,该按钮正在向控制台打印一条略有不同的消息,对吧?

不用说,它没有用。

我在 UI 方面做了什么

我有两个按钮,每个按钮都会生成一个带有不同文本的通知,还有一个动作按钮(据说)会做不同的事情。

包起来

那么,我需要做什么才能让两个(或更多)通知的操作按钮执行它们各自的操作?

非常感谢您的任何帮助,并提前表示感谢。

0 投票
1 回答
2858 浏览

swift - 为 OS X 创建交互式通知

Mac 基础知识:通知让您随时了解可以使用文本输入字段创建交互式警报的状态:

例如,您可以直接从通知回复聊天。

OS X 聊天提醒

我该如何实施?例如,我有一个通知:

0 投票
0 回答
829 浏览

ios - Iphone 7 plus 应用程序启动时出现跳板错误 iOS 10

在应用程序启动时,我的应用程序因以下堆栈跟踪而崩溃。奇怪的是,该应用程序在包括 iPhone 7 在内的任何其他 iOS 10 设备上运行良好,但在 iPhone 7 Plus 上崩溃。该错误看起来在新的 UserNotifications 框架中,但应用程序根本没有使用该框架。

0 投票
2 回答
9921 浏览

ios - iOS 10 [Objective C] 如何实现推送通知?

任何人都可以帮助我实现 iOS 10 的推送通知,因为我已经实现了以下代码,但仍然遇到问题:

我收到错误提示

未知接收者 UIUserNotificationCenter

先感谢您!