Search code examples
objective-cgksession

iOS GKSession Stop Searching Devices after a while of time


I want to develop an app that can send data between 2 or more iOS devices using bluetooth or wifi. I find GameKit framework can help me do that. My problems are:

  1. How can I stop searching devices process after a while of time without any devices found? I've implemented GKPeerPickerController and when I press my button it will start searching devices process. I want after 10 seconds if there is no devices found, I will stop searching and notify user that there's no devices near here.

  2. How can I specified that time for myself? Is there any property for me to set for the time like 10 seconds I indicated above.

Thanks


Solution

  • I've found that I can manage connection with GKSession, it doesn't need to use GKPeerPickerController. Just set property "available" of GKSession to YES or NO to start or stop searching devices to connect.