Mfmessagecomposeviewcontroller iOS7 Addattachmentdata:Typeidentifier:Filename: Not Working

MFMessageComposeViewController iOS7 addAttachmentData:typeIdentifier:filename: not working

The MFMessageComposeViewController wants the attachment to have the correct extension for the type of image you're uploading. I verified by testing with a PNG file, and the following variations of adding the attachment data:

[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image"];
[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image.abc"];
[messageController addAttachmentData:imgData typeIdentifier:@"public.data" filename:@"image.png"];

Only the last option worked. I didn't need to change the typeIdentifier, although it probably would make sense to choose a UTI that matches the type of data.

The full list of UTIs is available here: System-Declared Uniform Type Identifiers (Thanks @iWasRobbed!)

send audio with MFMessageComposeViewController

You need to set the filename to include a proper file extension, e.g. @"test.caf", instead of just @"test". See this answer for a similar question:
MFMessageComposeViewController iOS7 addAttachmentData:typeIdentifier:filename: not working

Attach a vCard to MFMessageComposeViewController

Adding attachment feature is added in iOS7 with the MFMessageComposeViewController class.
The method – addAttachmentData:typeIdentifier:filename: gives the answer where typeIdentifier can be set as kUTTypeVCard.

Can't Attach Image to MFMessageComposeViewController

As discussed in the comments, use addAttachmentURL:withAlternateFilename:. My guess is, the NSData object you provide does not fit the kUTTypePNG type and adding the attachment fails.



Related Topics



Leave a reply



Submit