UIActivityViewController cannot add image to imessage
Asked Answered
W

1

8

I'm using UIActivityViewController to share image on ios 6 and my code

        UIImage *shareImage = [UIImage imageNamed:@"myImage.png"];

        // Init array
        NSMutableArray *items = [NSMutableArray new];
        [items addObject:@""];
        [items addObject:shareImage];

        // Add image to paste board
        UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
        pasteboard.persistent = YES;
        pasteboard.image = shareImage;

        UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:items applicationActivities:nil];

        //This is an array of excluded activities to appear on the UIActivityViewController
        activityVC.excludedActivityTypes = @[UIActivityTypePostToWeibo,
                                             UIActivityTypePrint,
                                             UIActivityTypeCopyToPasteboard,
                                             UIActivityTypeAssignToContact,
                                             UIActivityTypeSaveToCameraRoll];

        [self presentViewController:activityVC animated:TRUE completion:nil];

Everything working fine but cannot paste shareImage to iMessage. I don't know why? Thank for your help!

Wendiwendie answered 27/3, 2013 at 10:11 Comment(5)
I don't think you can: #12593755Ursel
Text only with action sheet. You can share the image with mail and other options such twitter Facebook and so on but in iMessage it only allows text. You can look up cocoa controls one of those may have a costum class for that but as far as action sheet is conserned no luck man.Ghirlandaio
check my Answer : #15758663Automatic
@Vin: it's not workingWendiwendie
@Wendiwendie I'm using similar code to yours and I can confirm that the image now posts fine to iMessage in iOS7Sadoc
B
1

As others have said, iMessage only supports text, not images. Although it sounds like in iOS7, it does work.

I know personally I've gotten it to work with OvershareKit: https://github.com/overshare/overshare-kit .

It of course adds a bit of overhead but allows you to share with just about every medium there is with their slick interface/APIs.

Beliabelial answered 30/12, 2013 at 2:40 Comment(2)
will this accepted for Apple when uploading on itunes? Is there any code which violate apple's rule?Technic
Yes. It's accepted and used in two of my apps currently.Beliabelial

© 2022 - 2024 — McMap. All rights reserved.