What is the best practice to call URL in apple watch?

∥☆過路亽.° 提交于 2019-12-11 12:59:00

问题


What is the best practice to call API from Apple watch

  1. use sendMessage "watchConnectivity" from Apple watch to iPhone to call the API

or

  1. use NSURLSession to call the API from the watch itself ?

回答1:


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.

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




回答2:


Using NSURLSession directly from the watch was what Apple suggested in the WWDC labs, so I'd suggest #2.



来源:https://stackoverflow.com/questions/33854279/what-is-the-best-practice-to-call-url-in-apple-watch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!