Setting GKLocalPlayer.local.authenticateHandler may cause whole window to be obfuscated by alert "No Internet Connection"

My game supports both GameCenter, setting up a custom host and local games against bots. To log in to GameCenter and be able to handle invitations from other players, I set GKLocalPlayer.local.authenticateHandler after the app finished loading. But it seems that whenever I’m disconnected from the internet for more than 24 hours, setting GKLocalPlayer.local.authenticateHandler causes the whole window to be obfuscated by an alert telling me that I have no internet connection.

When this happens, if I connect to the internet and disconnect again, the alert is not shown anymore.

This is a huge problem because the alert prevents a user from using any other feature of the app unrelated to GameCenter, since there's no way to dismiss it.

Is this really intended behaviour or how is a user supposed to continue using the app that supports GameCenter and does not rely on it, while being disconnected from the internet?

I created FB22951946.

First of all, thanks for filing the feedback. This will help us investigate potential improvements here.

Looking at the authenticateHandler documentation, it seems to me that assigning the authenticate handler immediately triggers authentication.

The documentation also states that

Game Center may show a brief initialization screen if the player isn’t already signed into Game Center.

So it seems to me that since you're signed out in the described scenario, the "initialization screen" which would typically include a spinner or some UI, that would quickly go away after authenticating, you are presented with a much more permanent view.

I wonder the viewController provided by the callback can be inspected for the problematic state you are encountering? And perhaps dismissed manually?

The Authenticating a player documentation may include some more information that could be helpful. For example, you might consider assigning the authenticateHandler value at a different time, or in a different circumstance.

I think being intentional about when the authenticate handler is assigned may prove more robust than fiddling with the provided view controller.


-Dave

Hi Nickkk,

Thank you for your feedback. We should not be presenting this undismissable alert when your device is offline.

This is a known issue, and a fix is coming soon. In the meantime, could you work around this issue by deferring your call to set authenticateHandler until you've confirmed you have a network connection (with NWPathMonitor, for example)?

Thanks, I'll try NWPathMonitor as a workaround. And to clarify, this issue is caused by setting the authentication handler, but the handler is not even called when the alert is presented, so there's no way to manipulate the view controller.

Setting GKLocalPlayer.local.authenticateHandler may cause whole window to be obfuscated by alert "No Internet Connection"
 
 
Q