iGundersen
iGundersen

Reputation: 63

Dial a number when entering a location - iOS

I have a small question. Is it possible to create a small program that call a given number, when you get home (based on GPS). The garage door opens / closes by calling a number.

Upvotes: 2

Views: 616

Answers (2)

AAV
AAV

Reputation: 3803

just compare two location (home and current position) and call the number which will open gate. Simple way to do this is

CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:lat1 longitude:lon1];
double distance = [loc1 getDistanceFrom:position2];

if(distance <= 5 (any value you want)) {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:XXXXXX"]]; 
}

Upvotes: 1

turbo
turbo

Reputation: 1897

Yes it is possible.

You can use:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:XXXXXX"]]; 

(taken from: Call to a phone number through iPhone App)

You should be able to set it up to perform this function based on gps location. Just get the coordinates you need and pass them to a method. Test them to see if they fall within a certain range and if so, call the number.

Upvotes: 4

Related Questions