iOS 通知动态操作类别
<p><p>我需要通过有效负载显示推送通知的动态操作。像这样:</p>
<pre><code> {
Platform": "apns",
"Title":"Booking from API",
"Content": "Hello there",
"Category": "confirmBooking",
"Actions":[
{
"ButtonText": "Confirm",
"ActionName": "confirmBooking"
},
{
"ButtonText": "Decline",
"ActionName": "declineBooking"
},
]
}
</code></pre>
<p>它的好习惯是什么?到目前为止有可能吗? </p>
<p>目前我正在对类别使用静态配置,并且效果很好:</p>
<pre><code> var confirm_action = UNNotificationAction.FromIdentifier("confirm", "Confirm", UNNotificationActionOptions.None);
var decline_action = UNNotificationAction.FromIdentifier("decline", "Decline", UNNotificationActionOptions.None);
// Create category
var categoryID = "bookingConfirm";
var actions = new UNNotificationAction[] { confirm_action, decline_action };
var intentIDs = new string[] { };
var categoryOptions = new UNNotificationCategoryOptions[] { };
var category = UNNotificationCategory.FromIdentifier(categoryID, actions, intentIDs, UNNotificationCategoryOptions.None);
var categories = new UNNotificationCategory[] { category };
UNUserNotificationCenter.Current.SetNotificationCategories(new NSSet<UNNotificationCategory>(categories));
</code></pre>
<p>但不处理任务</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>到目前为止,我认为您无法通过有效负载显示推送通知的动态操作。iOS 系统不支持您这样做。</p>
<p>在 iOS 文档的 <code>UNNotificationAction</code> 部分,它写道:</p>
<blockquote>
<p>Because your app must handle all actions, you must declare the actions
that your app supports <code>at launch time</code>.</p>
</blockquote>
<p>可以引用:</p>
<p> <a href="https://developer.apple.com/documentation/usernotifications/unnotificationaction" rel="noreferrer noopener nofollow">https://developer.apple.com/documentation/usernotifications/unnotificationaction</a>
<a href="https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types" rel="noreferrer noopener nofollow">https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types</a> </p></p>
<p style="font-size: 20px;">关于iOS 通知动态操作类别,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/53048306/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/53048306/
</a>
</p>
页:
[1]