What is the best practice to call URL in apple wat

2019-08-14 06:53发布

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 ?

2条回答
▲ chillily
2楼-- · 2019-08-14 07:36

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

查看更多
女痞
3楼-- · 2019-08-14 07:40

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

查看更多
登录 后发表回答