Search code examples
iphonebluetoothmultiplayergkpeerpickercontroller

Issue using bluetooth on iPhone/iPod


I'm trying to set-up a bluetooth based communication between two iOS devices. Basically I'm trying to create a multiplayer game between two iPhones/iPods using bluetooth.

I'm using GKPeerPickerController to show the two options: Online or Nearby Game.

Problem: When I hit Nearby for the first time, nothing happens. I get the following log:

BTM: attaching to BTServer
2011-12-22 22:57:22.222 Plane Killer[144:707] <<< Picker >>> -[GKPeerPickerViewController _updatePicker:]: unhandled pending state: GKPeerPickerStateUnknown

Second time when I hit Nearby, I get the "alert" saying that my device is looking for other devices.

The funny thing is that I'm not able to find GKPeerPickerStateUnknown on the internet.


Solution

  • Seems that the problem appears only when I add both GKPeerPickerConnectionTypeNearby and GKPeerPickerConnectionTypeOnline.

    GKPeerPickerController *mPicker=[[GKPeerPickerController alloc] init];
    mPicker.connectionTypesMask = GKPeerPickerConnectionTypeNearby | GKPeerPickerConnectionTypeOnline;
    

    I will fix it by changing my UI. I will create my own buttons for playing online and nearby.