手表套件:是否可以以编程方式振动手表? [英] Watch Kit: is it possible to vibrate watch programmatically?

查看:76
本文介绍了手表套件:是否可以以编程方式振动手表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

手表扩展程序运行时是否可以振动手表?我们可以在 iOS 上这样操作(强制 iPhone 振动):

Is it possible to vibrate watch while Watch Extension is running? We can do it on iOS in this way (force iPhone to vibrate):

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

我希望 WatchKit 上也有类似的东西.

I hope there is something similar on WatchKit.

更新:我已将问题添加到 Apple 雷达并收到了答案:

Update: I have added issue to Apple radar and recieved the answer:

工程部已确定您的错误报告 (20019274) 与另一个问题 (19025053) 重复,因此将关闭.

Engineering has determined that your bug report (20019274) is a duplicate of another issue (19025053) and will be closed.

19025053 仍然打开.

19025053 is still open.

更新 2: AudioServicesPlayAlertSound() 不适用于具有任何声音 ID 的手表模拟器.好像不支持函数.

Update 2: AudioServicesPlayAlertSound() not working on watch simulator with any sound ID. Seems like function is not supported.

推荐答案

如果您的目标是 watchOS 2.0

要做到这一点,您需要做的就是在具有任何 WKHapticTypeWKInterfaceDevice 实例上调用 playHaptic.在下面的示例中,它将播放通知触觉.

To do this all you need to do is call playHaptic on a WKInterfaceDevice instance with any WKHapticType. In the example below it will play the notification haptic.

Swift 3

WKInterfaceDevice.current().play(.notification)

目标 C

[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];

您可以进一步阅读Apple WKInterfaceDevice 文档

这篇关于手表套件:是否可以以编程方式振动手表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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