I have an app that have an sendInAppSMS action inside it. It brings up a window with a pre entered body in the message. Problem is that pressing the cancel button doesn’t work. If I press send it sends the message but doesn’t close the window. So I have to close the app completely to get rid of it.
Someone out there who might have run in to this before? Tried to search here but couldn’t find a solution..
Cheers!
This is how my code looks like:
-(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];
}
}
I’m learning by doing, so I don’t expect answers but if you feel to help out, where do I put that it in this code?
Did you set up and implement MFMessageComposeViewControllerDelegate? Try this
Edit:
To set delegate: