UIActivityViewController cannot add image to imessage - ios

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!

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.

Related

How to share text and image(both) on whatsapp using UIActivityController : Objective C?

UIImage * imageShare = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:trackImagePath]]];
NSURL *urlLink = [NSURL URLWithString:linkstr];
SharingActivityProvider * share = [[SharingActivityProvider alloc]initWithPlaceholderItem:#"Ghaneely Share!"];
share.sharelink = urlLink;
share.sharelinkText = shareString;
NSArray *objectsToShare = #[imageShare,share];
activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = #[UIActivityTypePostToWeibo,UIActivityTypePrint,UIActivityTypeSaveToCameraRoll,UIActivityTypeAssignToContact,UIActivityTypeAirDrop];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:TRUE completion:nil];
I want to share text and image (both) on WhatsApp just like Android by using UIActivityController. It used to work before when I used share without SharingActivityProvider. But I need to post different text on facebook, twitter,etc ,hence I am using ActivityProvider(which I think should not be the problem). Now with the code above it is sharing only image.
What could be the issue?
From this way you can share text and video to whatsapp :-
NSString *URLString=#"http://video.app.com/video.php?";
NSURL *VideoURL=[NSURL URLWithString:#“URLString ”];
NSMutableArray *activityItems= [NSMutableArray arrayWithObjects:VideoURL,#"Hey, check out this video I've shared with you, it's awesome!", result1, nil];
self.activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
self.activityViewController.excludedActivityTypes = #[UIActivityTypePostToWeibo,UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,UIActivityTypeAirDrop];
[self presentViewController:self.activityViewController animated:YES completion:nil];
try this may be it will help you.

When Called From UIActivityViewController WhatsApp Freezes After a Recipient Is Selected

I am using UIActivityViewController to share my iOS app.
When WhatsApp is selected from the list of options, it takes me to the proper screen. I can move around, and all the buttons work.
However, once I select a recipient, WhatsApp freezes.
Does anyone know what's going on here? Has anyone encountered this bug before?
EDIT (Code Added)
Here's the code I'm using to call the UIActivityViewController:
- (void) sharePressed:(UIBarButtonItem *)sender {
NSString* shareText = #"Hello World!";
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:#[shareText] applicationActivities:nil];
[self presentViewController:controller animated:YES completion:nil];
NSLog(#"This method ran: sharePressed");
}
It's as basic as it gets. It works for everything except WhatsApp.
try this code
- (IBAction)shareButton:(UIBarButtonItem *)sender
{
NSString *textToShare = #"Look at this awesome website for aspiring iOS Developers!";
NSURL *myWebsite = [NSURL URLWithString:#"http://www.codingexplorer.com/"];
NSArray *objectsToShare = #[textToShare, myWebsite];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil];
NSArray *excludeActivities = #[UIActivityTypeAirDrop,
UIActivityTypePrint,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo];
activityVC.excludedActivityTypes = excludeActivities;
[self presentViewController:activityVC animated:YES completion:nil];
}
I think the error was actually an internal problem with either whatsapp or UIActivityViewController because my other apps that use UIActivityViewController couldn't share on whatsApp last night. This morning though, even though I didn't change anything in my code, everything works perfectly!
I think is a bug in WhatsApp after yesterday update.
Update: You can send an NSUrl instead of NSString.

Sending image to whatsapp with ActivityVC

I'm trying to share an image and text.
But when i'm trying to share using whatsapp i dont see the image and it doesnt get sent (i do see it when i'm trying to share to facebook or mail...).
Whats going on?
- (void)shareImage:(UIImage *)image
{
NSString *sharedMsg=[NSString stringWithFormat:#"Hello world"];
UIImage* sharedImg=image;
NSArray* sharedObjects=[NSArray arrayWithObjects:sharedMsg, sharedImg, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc]
initWithActivityItems:sharedObjects applicationActivities:nil];
activityViewController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityViewController animated:YES completion:nil];
}
#ozd,
if image Share then
see link : Share image/text through WhatsApp in an iOS app
& if Share Text
JBWhatsAppActivity Library: https://github.com/jberlana/JBWhatsAppActivity
using Below Code You can share Text , Link..etc, may be helpful to you.
WhatsAppMessage *whatsappMsg = [[WhatsAppMessage alloc] initWithMessage:#"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en" forABID:#""];
NSArray *applicationActivities = #[[[JBWhatsAppActivity alloc] init]];
NSArray *excludedActivities = #[UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeMessage];
NSArray *activityItems = #[#"Hey , I would like you to experience this fabulous app which helps you to create , store and share your MOMENTS. You can add your voice message to every photo and moments too !!!\n\nDownload the app from https://play.google.com/store?hl=en", whatsappMsg];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityViewController.excludedActivityTypes = excludedActivities;
[self presentViewController:activityViewController animated:YES completion:^{}];

UIActivityViewController mixing text and images and keeping the order

Is it possible to mix images and text and send them as MMS? UIActivityViewController will share an image with text underneath, but no matter how I order the text and images, the images always appear on top and the text on the bottom. If it's not possible with UIActivityViewController, is there another way?
The code I'm trying to use:
NSArray *activityItems = #[smallImage, #"Love", mediumImage, #"You", largeImage];
NSArray *applicationActivities = nil;
NSArray *excludeActivities = nil;
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;
[self presentViewController:activityController animated:YES completion:nil];
It produces this result:
But this is what I want:

UIActivityViewController Automatically 'Clicking' Link iOS 7

I have a basic UIActivityViewController sharing some text and a URL. The sharing options are Email, SMS, Twitter, and Facebook. Everything works fine in iOS 6 but in iOS 7 when I choose Twitter or Facebook, without touching anything my device automatically closes my app, opens Safari and goes to the URL I am trying to share. What could be causing this?
Code (CustomActivityItemProvider is a subclass to customize text based on sharer):
if ([UIActivityViewController class]) { // if class exists = ios6+
// Create array for sharing
CustomActivityItemProvider *textToShare = [[CustomActivityItemProvider alloc]
initWithStandardText:#"Text to share.\n"];
NSURL *urlToShare = iTunesShort ? iTunesShort : [NSURL URLWithString:iTunesLink];
NSArray *activityItems = #[textToShare, urlToShare];
// Show sharing view
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:TRUE completion:nil];
}
So I still don't know why only shortened URLs were causing this problem, but a solution that took care of it was to include the urlToShare in the textToShare.
// Create array for sharing
NSString *urlToShare = iTunesShort ? iTunesShort : iTunesLink;
NSString *textWithUrl = [NSString stringWithFormat:#"Text to share.\n%#", urlToShare];
CustomActivityItemProvider *textToShare = [[CustomActivityItemProvider alloc]
initWithStandardText:textWithUrl];
NSArray *activityItems = #[textToShare];

Resources