1

在我的手表扩展上收到本地通知时,我正在尝试显示自定义的 Long-Look UI。

我测试了这个示例 .apns 有效负载:

{
    "aps": {
        "alert": {
            "body": "Test message",
            "title": "Optional title"
        },
        "category": "myCategory",
        "thread-id":"5280"
    },

    "WatchKit Simulator Actions": [
        {
            "title": "First Button",
            "identifier": "firstButtonAction"
        }
    ],

    "customKey": "Use this file to define a testing payload for your notifications. The aps dictionary specifies the category, alert text and title. The WatchKit Simulator Actions array can provide info for one or more action buttons in addition to the standard Dismiss button. Any other top level keys are custom payload. If you have multiple such JSON files in your project, you'll be able to select them when choosing to debug the notification interface of your Watch App."
}

它工作正常。我还在故事板上设计了一个动态通知场景。

我正在像这样安排来自 iOS 端的本地通知(然后立即锁定手机以强制通知在我的手表上继续)

let content = UNMutableNotificationContent()
content.title = "Early bird"
content.categoryIdentifier = "myCategory"
content.userInfo = [
            "userData": [
                "WatchKit Simulator Actions": [
                    [
                        "title": "Button 1",
                        "identifier": "button1Action",
                    ],
                    [
                        "title": "Button 2",
                        "identifier": "button2Action",
                    ]
                ]
            ]
        ]

我想我设置userInfo错了。如何设置正确的有效负载,以便我的 watchOS 扩展可以正确呈现长视图?

4

0 回答 0