views:

63

answers:

2

hi all, my question is that i want to write a simple code in xcode, by which if i bring another iphone closer to mine, and make contact... then certain function is called ? help ..

A: 

You want the Gaming Kit. It has relatively simple means of handling peer-to-peer communications.

TechZen
+2  A: 

It is difficult to determine one iPhone striking another.

You might be tempted to use the geolocation tools, but they could only tell you when the two devices are within a few meters, and that's the best case scenario. What I would do would be to detect a sharp bang using the accelerometer and take note of the time at which it occurred, use the bluetooth communications provided by GameKit (perhaps) to ask connected devices if they had an equally sharp hit at this exact moment in time. If they did, then it could be likely (depending on how many devices you are tracking etc.) to adequately tell when one device 'strikes' another.

But this will only work well with significantly percussive movements, and you may need to do complex filtering of the accelerometer to refine your detection method.

Nex