I wanted to use my existing home screen widgets on watchOS as complications, but it fails in network requests, so it cannot receive and display data.
I added the necessary app transport security fields to my info.plist file, but nothing changed. The weird thing is that although it works fine on the emulator, it gives an internet error on the real device.
This is how I try to get the data from the API in "getTimeline"
let snap = lookupTeams(for: configuration)
let footballNext = Bundle.main.decode(FixturesWelcome.self, from: "NextMatch.json").response.first
var images: [ImagesFromAPI] = []
let nextLogo = try? Data(contentsOf: URL(string: footballNext?.teams?.home?.name == snap.team.name ? footballNext?.teams?.away?.logo ?? "" : footballNext?.teams?.home?.logo ?? "")!)
images.append(ImagesFromAPI(id: footballNext?.teams?.home?.name == snap.team.name ? footballNext?.teams?.away?.id ?? 0 : footballNext?.teams?.home?.id ?? 0, category: "next", image: nextLogo))
And here is the console output:
2022-09-27 00:14:17.969631+0100 Watch ExtensionExtension[716:446512] [connection] nw_endpoint_fallback_get_timeout_nanos [C1.1 media.api-sports.io:443 waiting fallback (unsatisfied (Path was denied by NECP policy), interface: en0, ipv4, fallback: {interface: ipsec0, agent: 504C854E-2C6D-45F6-B241-3C3492B926FA, weak, generation: 1007)] No RTT information for fallback interface, will use a default value 200ms
2022-09-27 00:14:19.453144+0100 Watch ExtensionExtension[716:446512] Connection 1: received failure notification
2022-09-27 00:14:19.453271+0100 Watch ExtensionExtension[716:446512] Connection 1: failed to connect 1:50, reason -1
2022-09-27 00:14:19.453304+0100 Watch ExtensionExtension[716:446512] Connection 1: encountered error(1:50)
2022-09-27 00:14:19.477070+0100 Watch ExtensionExtension[716:446510] Error getting network data status Error Domain=NSPOSIXErrorDomain Code=19 "Operation not supported by device"
2022-09-27 00:14:19.477245+0100 Watch ExtensionExtension[716:446510] Task <025FC0D5-2651-4602-9784-E3EFA6E0DA2F>.<0> HTTP load failed, 0/0 bytes (error code: -1009 [1:50])
2022-09-27 00:14:19.477426+0100 Watch ExtensionExtension[716:446510] NSURLConnection finished with error - code -1009