如何从不同的通知启动不同的苹果手表应用程序屏幕? [英] How to launch different screen of apple watch app from different notification?

查看:28
本文介绍了如何从不同的通知启动不同的苹果手表应用程序屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:

如何从不同的通知启动不同屏幕的 Apple Watch 应用?

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

这是我的设置:

我有 2 个静态 WKUserNotificationInterfaceController:

I have 2 static 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."

}

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

Once I received a notification, pressing the notification sash or "Details" Button will launch the watch app:

手表应用如何确定通知是来自 AwardsCategory 还是来自 otherCategories?然后我们可以从那里设置我们的初始控制器?

推荐答案

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

When the user taps a button on the notification, the main interface controller is always displayed. handleActionWithIdentifier:forRemoteNotification: is called on your main controller and you can update the UI there. For example, you could hide certain elements, or push a different controller.

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

(If the user taps on the sash, the identifier will be an empty string.)

这篇关于如何从不同的通知启动不同的苹果手表应用程序屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆