Включить данные полезной нагрузки APS в локальное уведомление для watchOS - PullRequest
0 голосов
/ 19 мая 2018

Я пытаюсь отобразить пользовательский интерфейс Long-Look при получении локального уведомления на моем расширении часов.

Я протестировал этот образец .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 могло корректно отображать длинный вид?

...