Skip to content

Instantly share code, notes, and snippets.

@nfarah86
Created May 7, 2016 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nfarah86/782b92a76cb9da5f92a1c2e283112ee1 to your computer and use it in GitHub Desktop.
Save nfarah86/782b92a76cb9da5f92a1c2e283112ee1 to your computer and use it in GitHub Desktop.
Send Coordinates to \update_run
// omitted code
- (void)sendUpdateRunRequestWithLocation:(CLLocation *)location
{
CLLocationCoordinate2D coordinate = [location coordinate];
//accuracy is important
CLLocationAccuracy accuracy = location.horizontalAccuracy;
//my database in server has a created (timestamp)
// invert time b/c comes out to (-)
//distinguish between bad and good cordinates by setting parameters
if(location!=nil&&accuracy>0
&&accuracy<2000
&&(!(coordinate.latitude==0.0&&coordinate.longitude==0.0))) {
NSMutableDictionary * dictOfCoordinates = [[NSMutableDictionary alloc]init];
dictOfCoordinates[@"latitude"] = @[ @(coordinate.latitude) ];
dictOfCoordinates[@"longitude"] = @[ @(coordinate.longitude) ];
NSLog(@"%@", dictOfCoordinates);
NSURL *url = [NSURL URLWithString:@"http://rescue-nfh.herokuapp.com/update_run"]; //URL refer to hostName
[self sendRequestToURL:url requestBody:dictOfCoordinates];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment