Question

I am developing the app in which i successfully integrated a bump API but recently bump developer site announce that bump API shutdown after 31st January.

Now i wondering about it's alternate way for doing this task in my application to implement without bump API.

I just trying use CPMotionRecognizer But i didn't know that help's me or not that only detect our device motion while use shake the device. But how to fine near Device that shake with our device like same as Bump API.

Please suggest to me its alternate way or suggestion.

Was it helpful?

Solution

If there is a server side involved in your app, you can get the coordinates of every device using CLLocationManager Class and then calculate the distance using following function.

#define d2r (M_PI / 180.0)

+(float) haversine_km:(float)lat1: (float)long1: (float)lat2: (float)long2
{
float dlong = (long2 - long1) * d2r;
float dlat = (lat2 - lat1) * d2r;
float a = pow(sin(dlat/2.0), 2) + cos(lat1*d2r) * cos(lat2*d2r) * pow(sin(dlong/2.0), 2); 
float c = 2 * atan2(sqrt(a), sqrt(1-a));
float d = 6367 * c;

return d;
}

Where lat1, long1 are the coordinates of first device and lat2, long2 are the coordinates of other device. The result will be in Kilometers and off course you can convert it to your desired unit. Then you can check if it is within your desired range.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top