在Apple Watch中调用URL的最佳做法是什么? [英] What is the best practice to call URL in apple watch?
问题描述
从Apple Watch调用API的最佳做法是什么
What is the best practice to call API from Apple watch
- 使用从Apple Watch到iPhone的sendMessage"watchConnectivity"调用API
或
- 使用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屋!