Reputation: 1198
I want to send an image with my text Message. I have used MFMessageComposeViewController
. This is the code i have done:
MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];
messageController.messageComposeDelegate = self;
NSArray *recipents = @[[arr_promoterDetaildata valueForKey:@"phone_number"], @"72345524"];
UIImage *img = [UIImage imageNamed:@"ic_dummy_img"];
NSData *imgData = UIImagePNGRepresentation(img);
BOOL didAttachImage = [messageController addAttachmentData:imgData typeIdentifier:(NSString *)kUTTypePNG filename:@"image.png"];
NSString *message = [NSString stringWithFormat:@"Sending SMS"];
[messageController setRecipients:recipents];
[messageController setBody:message];
if (didAttachImage)
{
// Present message view controller on screen
[self presentViewController:messageController animated:YES completion:nil];
}
else
{
UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Failed to attach image"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[warningAlert show];
return;
}
I have tried so many method’s but it is not attaching image in my message screen. Can anyone help?
Upvotes: 1
Views: 1049