iOS 7 Sandbox Game Center Live Matches not matching on Cellular connection - ios7

Auto matching works fine on a wifi connection using
[[GKMatchmakerViewController alloc] initWithMatchRequest:matchRequest];
However, when I switch both devices to use the cellular data connection then the match won't get created. It is just stuck looking for match "forever". Any ideas on what would be causing that? Is that as designed from Apple's matchmaking algorithm.

Related

How can i make sure my BLE peripheral (NRF52832) gets reconnected again after i have unpaired it?

A little new to NRF52, so please pardon if this turns out to be a noob question. I'm using nrf52832 as a peripheral and loading the standard SDK peripheral example of GATTS ( any other does result in the same).
After configuring that device i try to connect my phone to it , which happens succesfully. But after unpairing my phone and trying to configuring again my phone cant pair with the device.
Phone shows:
Could'nt pair .Check settings of this device.
Sniffer shows:
Rcvd pairing failed: Pairing not supported.
I do understand that some thing is getting stored in persistent memory. So how do i remove it or how do i load that data again.
Mobile app Logs:
Error 22 (0x16) GATT_CONN TERMINATE LOCAL HOST
Sounds like you've triggered one of the default security features of the nRF.
The nRF knows it has an encryption key with the phone (as it's been paired before), but the phone doesn't know the key (because you unpaired it and it deleted the key), so the nRF assumes someone is trying to spoof the real phone and drops the connection as defense.
Not sure which nRF SDK you're using, but if you search for peer_manager in the initialisation routine you should see an option to allow keys to be over-written.
Here's the relivent docs. One quick-fix, if security isn't a concern, is to delete all bonding info on the nRF with pm_peers_delete()

Communication is lost on wifi toggle and onDisconnect and onPeersDisconnected not being fired

I'm using code from Google's sample game "ButtonClicker2000" found here: https://github.com/playgameservices/android-basic-samples
I have 3 androids running this game in genymotion plus one on my own phone, debugging them all from android studio. I've gotten to a point where I'm trying to gracefully handle disconnect in the event of network issues. The way I'm simulating network issues is toggling the wifi on my phone. (on or off, same behavior) After that, real time messages from my phone are no longer being received by the virtual devices, and my phone is no longer receiving real time messages from the other devices. However, my phone never enters onDisconnect() and the other devices never enter onPeersDisconnected. If I exit the app on my phone after communication ceases, onPeerLeft fires on the other devices.
How can I either ensure communication between devices in a game isn't lost in the likely event that a user at some point comes in or out of range of their wifi? If that's not possible, how can I at least ensure the onDisconnect event is firing from the offending device and onPeersDisconnected event is firing on the others?
If we're going with what the documentation states, onDisconnect usually happens when there's a problem with the remote services (crash or resource problem). having the WiFi turned off doesn't look like it fits with those criteria. [onPeersDisconnected](https://developers.google.com/android/reference/com/google/android/gms/games/multiplayer/realtime/RoomStatusUpdateListener#onPeersDisconnected(com.google.android.gms.games.multiplayer.realtime.Room, java.util.List)) is called when the participants are disconnected from the room.
Determine if the onP2PConnected is called when its connected and onP2PDisconnected when disconnected (hopefully this can catch WiFi toggling cases) since I think its more appropriate when you're using real-time multiplayer.
You can also read more about it in the Real-time Multiplayer section of the documentaiton.
Hope this helps!

iOS 9.1 BLE Connects and Immediately Disconnects

When I connect to a BLE peripheral using encryption on iOS 9.1 using a iPhone 6S the BLE peripheral is immediately disconnected. I've verified that this works on iOS 8 and 9.02. I've validated that the CBCentralManager didConnect delegate method is being called and a valid CBPeripheral object is being returned.
The BLE peripheral is disconnected immediately. I'm not able to even proceed to discover any services or characteristics before it is disconnected. The CBCentralManager didDisconnect method is called, but no error is returned.
Is anyone else seeing this? This has been working correctly for over a year and like I said it's only happening when using iOS 9.1 on the iPhone 6S. Don't have any other peripherals on 9.1 to test with.
UPDATE
According to Apple the issue is happening because we're not bonding the peripheral with the iPhone. So we've updated the firmware on the peripheral and are now bonding. This is presenting different issues surrounding maintaining bonding pairs between the phone and the peripheral. Our peripheral has a limited amount of memory, so we cannot maintain an infinite amount of bond references. To handle this scenario the peripheral allows for a maximum of 8 BLE bonds to be stored. When it receives a ninth request the first bond is removed from the peripherals list of bonded devices. This presents an issue because the iPhone doesn't know this bond has been removed and when I try to connect with the first device and interact with a characteristic I'm not prompted to pair. Which from my understanding is what kicks off the encryption process.
I'm wondering if there is anyway to remove a bond / device from an iPhones list of bonded devices, other then going into the Bluetooth settings and 'Forgetting' the device.
UPDATE #2
Apple has confirmed that there is NOT a way to remove a bonded peripheral from the 'MY Devices' section within the Bluetooth settings in the application due to security issues.
Based on this the scenario has now turned into the following. The iOS device has a reference to what was once a bonded peripheral under "My Devices" however that peripheral no longer has a reference to the iOS device within it's bonded devices table.
When I attempt to connect the iOS device, which still has the bond reference in it, to the peripheral that no longer has the bond reference we can connect successfully. However, after I connect successfully I discover the characteristic, set it to notify and receive no response and no pairing message. The only solution that fixes this issue is going into 'Settings' and 'Forgetting' the device and then attempting to reconnect.
Has anyone else experience this issue? Suggestions?
Thanks!

iOS CoreBluetooth operating as a peripheral and central simultaneously in the background

I'm writing an app using CoreBluetooth in iOS8 that detects and connects to other phones using the app. I'm trying to figure out the best way to be able to create a connection while both apps are backgrounded, but have been having difficulty in the scenario where both phones are backgrounded + locked. I've followed the suggestions of this post:
How to detect nearby devices with Bluetooth LE in iOS 7.1 both in background and foreground?
I haven't been able to establish a connection when both phones are backgrounded + locked, but I've been able to get a connection where the peripheral and central are backgrounded + locked and I then unlock the central (central still in the background). When I unlock the peripheral though nothing happens. It also works when they are backgrounded but not locked.
So in order to allow a connection to be established when I unlock the "peripheral", I decided to create a central and peripheral on both phones to simultaneously scan and advertise. Whichever discovers the other first will then stop scanning/advertising and connect. I've run into problems with this method that are detailed in the following two questions:
Peripheral and central at the same time on iOS
iOS CoreBluetooth Simultaneous Peripheral and Central Managers
Basically, I think that when both of my devices try to connect to each other simultaneously, they get hung up on attempting to connect and didConnectPeripheral is never called on either of them (the last thing both of them displays is a message saying that they are attempting to connect). It has worked occasionally though so I'm also a little confused as to why there is a probabilistic nature to the connection. Does anyone have any suggestions on how to approach the problem? If there's a better way to establish a connection when both apps are backgrounded + locked, please let me know because that was my original problem.
Thanks!
Declare bluetooth-central and bluetooth-peripheral background modes in your Info.plist to act in both Central and Peripheral roles in background.

GameKit (GKSession) : Is there a priority order when GKSession decides to use Wifi or Bluetooth (if both are available)

If I have two iOS devices, both on same WiFi network and both with Bluetooth turned on, and I use GameKit (specifically GKSession) to manually setup a communications channel between them (without using GKPeerPickerController), I cant tell if it is using WiFi or Bluetooth.
Does iOS prioritise one over the other? I'm hoping that it uses Wifi before Bluetooth, but id like to be sure.
If WiFi is available and bluetooth isn't, it uses Wifi, if Bluetooth is available and Wifi isn't, it uses Bluetooth. Im wondering how they're talking if both bluetooth and WiFi are available, which does GameKit choose over the other?
The only way I can see to find this out is by running a packet sniffer on my WiFi and running several tests across different devices. Kinda hoping someone can save me that effort!
Thanks :-)
According to Apple's documentation if you use a GKPeerPickerController to create your GKSession you will be able to select bluetooth or wifi connectivity (see GKPeerPickerConnectionType).
I'm hoping that it uses Wifi before Bluetooth, but id like to be sure.
It seems an internet connections requires a bit of user code (but not bluetooth) so I would guess it defaults to bluetooth to avoid making this requirement mandatory.