I want to send image and text to iMessage from my own application in ios5.
Is it possible to send image to iMessage from the app?
If yes, then what is the coding of it and which frameworks should I add in my app?
I want to send image and text to iMessage from my own application in ios5.
Is it possible to send image to iMessage from the app?
If yes, then what is the coding of it and which frameworks should I add in my app?
Here is what i have done to send .mp4 as attachment on message
in your .h file #import and MFMessageComposeViewControllerDelegate>
and methods in your .m file
-(void)sendMovieWithMessage{
MFMessageComposeViewController* messageComposer = [MFMessageComposeViewController new];
messageComposer.messageComposeDelegate = self;
[messageComposer setBody:@""];
NSData *attachment = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:[self bringFilePathfromDocumentsDirectory:@"your file.mp4"]] options:NSDataReadingUncached error:nil];
[messageComposer addAttachmentData:attachment typeIdentifier:@"video/mp4" filename:@"your file.mp4"];
[self presentViewController:messageComposer animated:YES completion:nil];
}
//Delegate
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{
[self dismissViewControllerAnimated:YES completion:^{
}];
}
NO this is not possible, first of you will need to use MFMessageComposeViewController
which only supports text.
Also there is no way to detect if the message will be send via iMessage
Although this is an old questions, I just wanted to add this to help out the guys that find this on google:
For the below code to work you have to import:
#import <MessageUI/MessageUI.h>
And have the MessageUI.framework
linked in your build settings (Project Name > Build Phases > Link Binary with Libraries
)
My code below works for video and image, so you have to set it to either one:
NSString *attachmentType = @"image";
or NSString *attachmentType = @"video";
also you have to set the attachment
NSData:
NSData *attachment = UIImageJPEGRepresentation(YOUR_IMAGE,.5)
This was an example of setting an image. The .5
is the image quality and I found that it is a good tradeoff between quality and size. 1.0
is the best quality (and largest size!)
MFMessageComposeViewController* messageComposer = [MFMessageComposeViewController new];
messageComposer.messageComposeDelegate = self;
[messageComposer setBody:message];
[messageComposer setRecipients:recipients];colorForUsage:SC_THEME_MAIN];
if (attachment && attachmentType) {
if ([attachmentType isEqual:@"image"]) {
[messageComposer addAttachmentData:attachment typeIdentifier:@"image/jpeg" filename:@"shotnote.jpg"];
}
if ([attachmentType isEqual:@"video"]) {
[messageComposer addAttachmentData:attachment typeIdentifier:@"video/mp4" filename:@"shotnote.mp4"];
}
}
[YOUR_CURRENT_VIEW_CONTROLLER
presentViewController:messageComposer
animated:YES
completion:nil];
Also make sure to implement the MFMessageComposeViewControllerDelegate
protocol, to be able to actually close the message compose view controller when the user presses send or cancel!
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
Cheers!
you send it out the same way you would SMS - if the account you send to is iMessage enabled, then it will send out to iMessage. Apple ios5 iMessage read and write http://developer.apple.com/library/ios/#documentation/MessageUI/Reference/MFMessageComposeViewController_class/Reference/Reference.html#//apple_ref/doc/uid/TP40009668
As far as detecting in your app if someone has iMessage or not... i'm not sure you can.