Created
May 7, 2016 01:38
-
-
Save nfarah86/782b92a76cb9da5f92a1c2e283112ee1 to your computer and use it in GitHub Desktop.
Send Coordinates to \update_run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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