【问题标题】:iOS Notification Dynamic Action CategoriesiOS 通知动态操作类别
【发布时间】:2018-10-29 15:03:38
【问题描述】:

我需要通过有效负载显示推送通知的动态操作。像这样:

 {
Platform": "apns",
    "Title":"Booking from API",
    "Content": "Hello there",
    "Category": "confirmBooking",
    "Actions":[
        {
            "ButtonText": "Confirm",
            "ActionName": "confirmBooking"
        },
        {
            "ButtonText": "Decline",
            "ActionName": "declineBooking"
        },
    ]
}

它的好习惯是什么?到目前为止有可能吗?

目前我正在对类别使用静态配置,并且效果很好:

        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));

但不处理任务

【问题讨论】:

    标签: ios xamarin push-notification xamarin.ios apn


    【解决方案1】:

    到目前为止,我认为您无法通过有效负载显示推送通知的动态操作。iOS 系统不支持您这样做。

    在 iOS 文档的 UNNotificationAction 部分,它写道:

    因为您的应用必须处理所有操作,所以您必须声明这些操作 你的应用支持at launch time

    可以参考:

    https://developer.apple.com/documentation/usernotifications/unnotificationaction https://developer.apple.com/documentation/usernotifications/declaring_your_actionable_notification_types

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-16
      • 2014-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-23
      • 2015-07-01
      相关资源
      最近更新 更多