use*_*368 9 cocoa-touch ios watchkit
当用户在手机上打开应用程序时,有没有办法检测手机是否配对/连接到苹果手表?
Bil*_*fas 24
所以在WatchOS 2上这是可能的!
你必须在iPhone方面做:
第一:
import WatchConnectivity
Run Code Online (Sandbox Code Playgroud)
然后 :
if WCSession.isSupported() { // check if the device support to handle an Apple Watch
let session = WCSession.defaultSession()
session.delegate = self
session.activateSession() // activate the session
if session.paired { // Check if the iPhone is paired with the Apple Watch
// Do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
我希望它会帮助你:)
Mik*_*son 10
没有内置方法(至少在WatchKit SDK中)来确定Watch是否已与iPhone配对.一个常见的策略是将BOOL写入共享的NSUserDefaults(使用应用程序组),以便iPhone知道Watch应用程序至少运行过一次.这是我在自己的应用程序中使用的技术.
| 归档时间: |
|
| 查看次数: |
3598 次 |
| 最近记录: |