Checking for connectivity impossible in background URLSession?

To check for connectivity we should either:

  1. Set waitsForConnectivity = true and then monitor taskIsWaitingForConnectivity, or
  2. Set waitsForConnectivity = false and then fail immediately

However background sessions always wait for connectivity AND never call taskIsWaitingForConnectivity.

Huh?

In our case, at the time user is initiating downloads the "background" session is actually in the foreground and we need this information. What am I missing?

  • Filed bug FB13079231

Add a Comment

Replies

However background sessions always wait for connectivity

Yes.

AND never call taskIsWaitingForConnectivity.

Yes.

I think you could reasonably argue that a background session should call urlSession(_:taskIsWaitingForConnectivity:) when the app is in the foreground. If you want to make a case for that, I encourage you to file a bug about it. Please post your bug number, just for the record.

we need this information.

What do you plan to do with it?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

  • For convenience, users can disable downloads over cellular right in the app. But if they have cell data turned off (which means we set allowsCellularAccess = false) AND are not connected to wifi, the download just hangs there and doesn't error out.

Add a Comment