如何从 iOS 应用程序以编程方式打开 Apple Watch 配套应用程序 [英] How to programmatically open Apple Watch companion app from iOS app

查看:23
本文介绍了如何从 iOS 应用程序以编程方式打开 Apple Watch 配套应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提示用户,我的 iOS 应用支持 Apple Watch.

I would like to give a hint to the user, that my iOS app supports the Apple Watch.

所以我想从我的 iOS 应用程序中链接/打开 Apple Watch 配套应用程序,非常类似于使用 ([[UIApplication sharedApplication] openURL: [NSURL URLWithString:UIApplicationOpenSettingsURLString]]; 打开设置应用程序);)

So I would like to link/open the Apple Watch companion app from within my iOS app, very much similar to opening the Settings App using ([[UIApplication sharedApplication] openURL: [NSURL URLWithString:UIApplicationOpenSettingsURLString]];)

这将使用户能够直接导航到 Watch 配套应用来为手表设置我的应用.

This shall enable the user to directly navigate to the Watch companion app to setup my app for the watch.

我找不到任何可以打开配套应用的一般性或特定于配套应用部分的网址.

I could not find any URL which would open the companion app in general or specific to a section of the companion app.

如果不支持直接链接,我也对这个用例的替代方法感兴趣.

If direct linking is not supported, I am also interested in alternative approaches for this use case.

提前致谢!

我检查了模拟器中的 WatchKitSettings Info.plist 文件,看看它是否注册了任何 URL 模式,但它没有.

I checked the WatchKitSettings Info.plist file in the simulator to see if it registers any URL schema, but it does not.

推荐答案

我想不可能从 iOS 以编程方式启动手表配套应用程序.相反的方式是可能的:在收到来自手表的消息后在后台启动 iOS 应用程序.请参阅 WWDC 谈话介绍手表连接.

I guess it's not possible to programmatically launch the watch companion app from iOS. The opposite way would be possible: to launch the iOS app in the background upon receiving a message from the watch. See WWDC talk Introducing Watch Connectivity.

您可以检查 WCSession.defaultSession().watchAppInstalled 并要求用户启动应用程序,如果它是真的.

You could check WCSession.defaultSession().watchAppInstalled and ask the user to launch the app if it is true.

这篇关于如何从 iOS 应用程序以编程方式打开 Apple Watch 配套应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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