在本地通知中包含APS有效负载数据到watchOS

时间:2018-05-19 00:16:29

标签: ios apple-push-notifications watchkit unusernotificationcenter watch-os-4

我正在尝试在手表扩展程序上收到本地通知时显示自定义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扩展可以正确呈现长视图?

0 个答案:

没有答案