I\'m trying to get my app to be able to send its current GPS location through an SMS to a preentered phone number.
I have my code right now that only brings up an SMS w
Firstly add core location framework in Your Project. and call this method for finding current location.
-(IBAction) sendInAppSMS:(id) sender
{
MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease];
if([MFMessageComposeViewController canSendText])
{
CLLocation *location=[self findCurrentLocation];
CLLocationCoordinate2D coordinae=[location coordinate];
controller.body =[[NSString alloc] initWithFormat:@" Alarm!, call the senders number with latitude:%f longitude:%f",coordinae.latitude,coordinae.longitude]; ;
controller.recipients = [NSArray arrayWithObjects:@"phonenumber1", @"phonenumber2", nil];
[self presentModalViewController:controller animated:YES];
}
}
-(CLLocation*)findCurrentLocation
{
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
if ([locationManager locationServicesEnabled])
{
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.distanceFilter = kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
}
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
return location;
}