在 Apple Watch 中调用 URL 的最佳做法是什么? [英] What is the best practice to call URL in apple watch?

查看:44
本文介绍了在 Apple Watch 中调用 URL 的最佳做法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从 Apple Watch 调用 API 的最佳实践是什么

What is the best practice to call API from Apple watch

  1. 使用sendMessage "watchConnectivity" 从Apple watch 到iPhone 调用API

  1. 使用 NSURLSession 从手表本身调用 API 吗?

推荐答案

使用 NSURLSession API,从开发者那里抽象出执行请求的设备.如果手机可用,它将在手机上执行请求并将其返回到您的手表应用程序,就像手表本身执行请求一样.如果手机不可用,如果有已知的 2.4 GHz 网络可用,手表可以自行执行请求.

Using the NSURLSession API, the device that performs the request is abstracted from the developer. If the phone is available, it will perform the request on the phone and return it to your watch app as if the watch itself performed the request. If the phone is not available, the watch can perform request on its own if there is a known 2.4 GHz network available.

答案是 NSURLSession.这样你就不必担心通过 WatchConnectivity 框架在手机和手表之间传递信息,NSURLSession 为你做

The answer is NSURLSession. That way you don't have to worry about passing info between the phone and watch with the WatchConnectivity framework, NSURLSession does it for you

这篇关于在 Apple Watch 中调用 URL 的最佳做法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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