Send an Image with MSMessage

843 views Asked by At

I'm finishing the iMessage Extension but I've a little problem, I want to send a simple Image using MSMessage. Now I Use this Code :

 MSMessage *message = [[MSMessage alloc] init];  
    MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc]init];  

    [layout setImage:myImage];  
     message.layout = layout;  

    [savedConversation insertMessage:message completionHandler:^(NSError *error) {  

    }];  

But I don't want to use the MSMessateTemplateLayout like this: Standard Layout

I want only send a simple Image. How can I do this?

Thanks

EDIT :

I find the solution :

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

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

NSString *stringURl = [NSString stringWithFormat:@"%@%@",NSTemporaryDirectory(),@"temp.jpg"];


NSURL *urlImage = [[NSURL alloc]initFileURLWithPath:stringURl];


NSData *dataImage = UIImageJPEGRepresentation([self imageWithView:self.myViewBgImageConLogoDaSalvare], 0.0);
        [dataImage writeToURL:urlImage atomically:true];

[savedConversation insertAttachment:urlImage withAlternateFilename:nil completionHandler:^(NSError * error) {

        }];
0

There are 0 answers