检查 iPhone 是否与 Apple Watch 配对? [英] Check if iPhone is paired with apple watch?

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

问题描述

在我的应用程序中,

我需要查找我的手机是否与 Apple Watch 配对,并获取有关配对手表的一些信息,例如其名称.我尝试阅读文档,但似乎找不到任何特定于我的用例的内容.

I need to find if my phone is paired with a apple watch and get some information about the paired watch like its name. I tried reading the documentation but I couldn't seem to find any thing specific to my use case.

感谢任何帮助.

推荐答案

所以自从 WatchOS 2 以来,这是可能的!

So since 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.default()
        session.delegate = self
        session.activate() // activate the session

        if session.isPaired { // Check if the iPhone is paired with the Apple Watch
                // Do stuff
        }
    }

希望对你有帮助:)

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

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