如何从不同的通知启动不同屏幕的苹果手表应用程序?

How to launch different screen of apple watch app from different notification?

问题:

如何从不同的通知启动不同屏幕的苹果手表应用程序?

这是我的设置:

我有 2 个静态 WKUserNotificationInterfaceController:

1) 奖项类别

2) 其他类别

这是我用于 "awardsCategory" 通知的 PushNotificationPayload.apns 文件:

{
"aps": {
    "alert": {
        "body": "Hello world!",
        "title": "Optional title"
    },
    "category": "salaryCategory"
},

"WatchKit Simulator Actions": [
                               {
                               "title": "Details",
                               "identifier": "detailsButtonAction"
                               }
                               ],

"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."

}

收到通知后,按通知框或 "Details" 按钮将启动手表应用程序:

watch app如何判断通知是来自awardsCategory还是来自otherCategories?从那里我们可以设置我们的初始控制器?

当用户点击通知上的按钮时,始终显示主界面控制器。 handleActionWithIdentifier:forRemoteNotification: 在您的主控制器上调用,您可以在那里更新 UI。例如,您可以隐藏某些元素,或推送不同的控制器。

(如果用户点击窗框,标识符将为空字符串。)