Initiating new MSMessage from host app?

Let's say I have an existing app that has content that would make sense for the user to send to a friend as an interactive iMessage.


Is there currently any way to initiate the creation of a MSMessage with custom content from the app itself?

It does not look like the MFMessageComposeViewController has been extended to handle the creation of MSMessage objects?


If interactive iMessages can not be created directly in the host app, is it possible to launch iMessage with the app's extension and pass along some data?

Are there are any possible was to send MSMessage from another application extension. It works for me when I'm sending MSMessage from hosting applicaiton, but from Share Extension - it doesn't show message in the conversation - it looks like a bug. Becasue I'm able to send text message from Share extension.

Artmin,

I have follower your example and all 9 steps. However, when the iMessage screen appears, it is always empty. Any thoughts on what I may have missed?

I am trying to send an image, a url, and text. They show in the iMessage screen if I add the url and text in the "set body()" and add the image via "attachment()". When I try to use MSMessage, and set the properties in the new 'message' property of MFMMessageComposeViewController, the iMessage screen is empty.

I have added the Message Extension and configured it similarly to my other app extension (Share Extension).


Here's my code.

if([MFMessageComposeViewController canSendText] && [MFMessageComposeViewController canSendAttachments]) {

if (url != nil) {

MSMessage *newMsg = [[MSMessage alloc]init];

newMsg.URL = url;

MSMessageTemplateLayout *msgLayout = [[MSMessageTemplateLayout alloc] init];

msgLayout.caption = @"Caption";

msgLayout.imageTitle = @"Title for Image";

msgLayout.image = image;

newMsg.layout = msgLayout;

MFMessageComposeViewController *messageController = [[MFMessageComposeViewController alloc] init];

messageController.message = newMsg;

messageController.messageComposeDelegate = self;

[messageController setRecipients:nil];

[messageController setBody:@"body"];

/

[self presentViewController:messageController animated:YES completion:nil];

}

}

i have the same problem

don't possible add image in attachment Data ?

the message is empty !!!!!!


if (MFMessageComposeViewController.canSendText() && MFMessageComposeViewController.canSendAttachments()) {
            let message = MFMessageComposeViewController()
            message.body = "This is new Text"
            message.recipients = [(btnTel01.titleLabel?.text)!]
            message.messageComposeDelegate = self
           let image:UIImage = UIImage(named: "TextImage")!
            imageContact.image = image
            let dataImage =  UIImageJPEGRepresentation(image, 1)
            guard dataImage != nil else {return}
            /
            message.addAttachmentData(dataImage!, typeIdentifier: "image/.jpeg" , filename: "Icon")
           
            present(message, animated: true, completion: nil)
        } else {
            print("SMS services are not available")
        }
Initiating new MSMessage from host app?
 
 
Q