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
Uicollectionview's Cellforitematindexpath Is Not Being Called
Sending Push Notifications to iOS from Pwa
How to Change "Initwithnibname" in Storyboard
How to Get Distance of Object from iPhone Camera Using Image Exif Meta Data
iOS 8 - Screen Blank After Dismissing View Controller with Custom Presentation
How to Set a Custom View's Intrinsic Content Size in Swift
Making an Array of Integers in iOS
Saving PDF Files with Swift in iOS and Display Them
Cllocationmanager and Accuracy Issues - Any Experiences
Disable Scroll on a Uiwebview Allowed
Using iOS Gamekit's "Bluetooth Bonjour" with Other Platforms
Bringing a Subview to Be in Front of All Other Views
How to Add Done Button on Keyboard on Top of Keyboard in iOS
Uiview.Animatewithduration Swift Loop Animation
Swift Access Control with Target Selectors
Using Custom Fonts with Xcode 6/iOS 8 Interface Builder Launch Screen