简体   繁体   English

推送通知上的三个按钮

[英]Three buttons on push notification

I want to have 3 buttons on push notification. 我想在推送通知上有3个按钮。 I followed this tutorial for adding buttons. 我按照教程添加了按钮。 But this creates only two buttons. 但这只会创建两个按钮。 I modified the code to add another button but it seems that it all depends on destructive property of UIMutableUserNotificationAction . 我修改了代码以添加另一个按钮,但似乎这一切都取决于UIMutableUserNotificationAction 破坏性属性。 It can be either true or false. 它可以是真的也可以是假的。
How may I add a third button ? 我该如何添加第三个按钮?

Currently its not possible, max of 2 actions can be kept in notification in Minimal Context (UIUserNotificationActionContextMinimal) but you can have upto 4 actions in Default Context (UIUserNotificationActionContextDefault) 目前不可能,最小2个动作可以保存在最小上下文(UIUserNotificationActionContextMinimal)中的通知中,但在默认上下文中可以有最多4个动作(UIUserNotificationActionContextDefault)

Minimal Context defines the actions which will be visible on swiping the notifications. 最小上下文定义了在滑动通知时可见的操作。 Default context is when the notification is shown as an alert. 默认上下文是通知显示为警报的时间。 From iOS10 onwards it might be possible to have more buttons as Apple is introducing 2 new frameworks ie, UserNotification, UserNotificationUI 从iOS10开始,随着Apple推出2个新框架,即UserNotification,UserNotificationUI,可能会有更多按钮。

https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewIniOS/Articles/iOS10.html#//apple_ref/doc/uid/TP40017084-DontLinkElementID_2 https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewIniOS/Articles/iOS10.html#//apple_ref/doc/uid/TP40017084-DontLinkElementID_2

You can have more than 2 buttons in notification if notification type selected as alerts from iOS device setting. 如果通知类型被选为iOS设备设置的警报,则通知中可以有两个以上的按钮。 unless in notification tray or device lock mode then you will get only 2 buttons. 除非在通知托盘或设备锁定模式下,您将只获得2个按钮。

destructive property is different thing, when you keep it "true" that button will display with red color, default it is "false" and display button with blue color when you slide notification. 破坏性属性是不同的东西,当你保持“真”这个按钮会显示红色时,默认它是“假”并且当你滑动通知时显示蓝色的按钮。

在此输入图像描述

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

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