0
votes

In the old GameKit framework (the parts that are deprecated in iOS 7.0) the GKSessionDelegate contained a required method session:didFailWithError: for detecting errors.

This could be used for detecting if the network was unavailable for example, as it would return a GKSessionCannotEnableError if the Wi-Fi and bluetooth were currently disabled. In iOS 7.0 this was deprecated and replaced by the Multipeer Connectivity Framework and the MCSession class, however the MCSessionDelegate used to retrieve information from this class does not seem to have any error detection on it.

The MCNearbyServiceAdvertiserDelegate does have a method advertiser:didNotStartAdvertisingPeer: for detecting if the peer could not start advertising its service, which curiously does not get called even if airplane mode is on when the advertiser is started. In fact it seems that even in airplane mode with the Wi-Fi and Bluetooth off it still somehow advertises itself and can be detected by the browser on another device, but it does not seem to receive any invitations from other devices.

Is there any way to get error information and detect whether the Multipeer Connectivity classes cannot currently reach other devices?

1

1 Answers

0
votes

There's nothing in the MultipeerConnectivity framework itself that will do what you are asking. However, I am sure that if you used the lower-level peer discovery code (e.g. NSNetService or the Bonjour C API, for example), then you could use these frameworks to determine connectivity.

Otherwise, perhaps you could add a UI view that shows up after you have been browsing for peers and have not found any after a set time that suggests a few troubleshooting steps (turn on WiFi or Bluetooth or both; verify other device has network services on; etc).