如何检查iPhone和Apple Watch是否已连接 [英] How to check whether iPhone and apple watch are connected

查看:52
本文介绍了如何检查iPhone和Apple Watch是否已连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在 Apple Watch 中通知用户 iPhone 现在超出范围以及何时回到范围内.我们如何在手表扩展程序中做到这一点.

Is there any way to notify user in Apple Watch that the iPhone is now out of range and when it comes back in range. How can we do it in watch extension.

提前致谢.

推荐答案

所以在 WatchOS 2 上是可能的!

So on WatchOS 2 that is possible !

你必须在 iPhone 端做:

You have to do on iPhone side :

第一:

import WatchConnectivity

然后:

   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
        }
    }

希望对你有帮助:)

这篇关于如何检查iPhone和Apple Watch是否已连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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