IOS 通知内容扩展:在情节提要中添加按钮并处理点击操作

IOS notification content extension: add buttons in storyboard and handle the click action

IOS通知内容扩展:在MainInterface.storyboard中添加按钮并处理点击操作而不关闭通知

经过一些研究,我发现: 无法处理 IOS 通知内容扩展中的按钮点击,只能使用媒体按钮类型的按钮,请参阅 IOS 文档:

https://developer.apple.com/documentation/usernotificationsui/unnotificationcontentextension

上面的答案不正确,你可以在info.plist中加上UNNotificationExtensionUserInteractionEnabled YES,然后你就可以像普通的那样做每件事了viewController

作为Abdullah S. Al-Hallak said, it is not possible to perform actions that will lunch a certain screen. In Apple documentation,提到“不要在界面中安装手势识别器或依赖触摸事件”。

唯一可能的方法是添加仅在显示的通知中执行某些操作的操作(如动画,如这个酷炫 post 中所示:Adding a Custom UI and Interactivity in Local and Push Notifications