I am using a table view and i am using it to display clips which i am fetching from core data. Now i have an API for clip path which will connect it to the server clips i want to pass clip id with that API and pass the clip name fetched from the core data.i have tried following thing to make it work but gives me error.I think i am doing it wrong. How would i do that.
//here is my code but it is giving me error. Can't pass it this way.
NSArray * activityItems = #[[NSURL URLWithString:#"http://example.com/view-videos.html?task=clip.details&id=%#",_fetchid]]; // this is giving me error and here i also want to send selected clip name with this API
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:videoToShare applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,UIActivityTypePostToWeibo,UIActivityTypeCopyToPasteboard,UIActivityTypeMessage];
[self presentViewController:activityVC animated:YES completion:nil];
}
Try something like this. You are passing some other object not activityItems.
NSString *urlString = [NSString stringWithFormat:#"http://example.com/view-videos.html?task=clip.details&id=%#",fetchid];
NSArray * activityItems = #[[NSURL URLWithString:urlString]];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePostToFacebook,UIActivityTypePostToTwitter,UIActivityTypePostToWeibo,UIActivityTypeCopyToPasteboard,UIActivityTypeMessage];
[self presentViewController:activityVC animated:YES completion:nil];
If you want to share some video then also add that video in activityItems array object
Hope this will help you.
Related
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.
I am using UIActivityViewController like so:
NSData *pdfData = [NSData dataWithContentsOfFile:filePath];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:#[pdfData] applicationActivities:nil];
activityController.popoverPresentationController.sourceView = self.view;
[self presentViewController:activityController animated:YES completion:^{}];
I am wondering if there is a method I can use for when the use is finished using the UIActivityViewController (Cancel, Message, Mail, etc.)
How would I go about doing this?
Use the completionWithItemsHandler property of the UIActivityViewController to specify code that should run when the user is done with it.
Reference: Determine which share extension was used
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:^{}];
Below given code, I'm sharing 1 text and 2 photos using UIActivityViewController. Then I choose Facebook for my sharing destination and it's shared on 2 separated posts on the feed for each photo but what I want is to share it in one single post with 1 text and 2 photos. How can I achieve this? I have done lot of search on here and found no proper answer. It seems to me that Facebook may have no clear way to do this, so it's like such an issue may lie on their side.
activityItems = #[self.textDetail.text, self.imageFileView1.image, self.imageFileView2.image];
UIActivityViewController *activityController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
The issue was solved by either new iOS ver or Facebook's new way of handling activity items. Anyway it works as I expect now.
Try this:
NSString *message = #"msg To post";
NSMutableArray *postsImages=[[NSMutableArray alloc] init];
[postsImages addObject:message];
for (UIImage *img in collectionImageArray) {
[postsImages addObject:img];
}
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:postsImages
applicationActivities:nil];
[activityVC setCompletionWithItemsHandler:^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
if([activityType isEqualToString:UIActivityTypePostToTwitter]){
//twitter selected
}
}];
[self presentViewController:activityVC animated:YES completion:nil];
How do I send an email using UIActivityViewController with a quick message and a link? I have tried using an NSURL:
NSURL *url = [NSURL URLWithString:#"http://google.com/"];
And an NSString:
// String with Hyperlink syntax
NSString *stringURLHyperlink = #"Google";
// Plain text link out of desperation.
NSString *stringURLPlain = #"http://google.com/";
I am not using a custom UIActivity. The NSString/NSURL are being sent as activityItems:
NSArray *activityItems = #[link];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
Thanks everyone.
EDIT 1:
My apologies, I should have made my question clearer. How can I send a message and a clickable link in an email using UIActivityViewController?
This seems to work fine in iOS 7:
[[UIActivityViewController alloc] initWithActivityItems:#[#"<html><body><b>This is a bold string</b><br\\>Check out this amazing site: <a href='http://apple.com'>Apple</a></body></html>"] applicationActivities:nil];
If you share an object that conforms to the UIActivityItemSource protocol, then you will be able to specify what the email's subject should be too!
tl;dr: Use basic html in an NSString to wrap the desired email contents
In my case, I did not need to post a photo as long as an image was retrieved from the link I needed to share (just like when you post a link on your Facebook timeline and it automatically grabs a picture from that link, and the picture becomes the link). In order to do that, I figured out that if I posted only an URL it does not work. You have to post some initial text and then the URL, and you do so by putting the objects in that order within the activityItems array.
This is my working code:
NSArray * activityItems = #[[NSString stringWithFormat:#"Some initial text."], [NSURL URLWithString:#"http://www.google.com"]];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = #[UIActivityTypeAssignToContact, UIActivityTypeCopyToPasteboard, UIActivityTypePostToWeibo, UIActivityTypePrint, UIActivityTypeMessage];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;
[self presentViewController:activityController animated:YES completion:nil];
I also noticed that if you post a photo along these objects, it will not retrieve any image from the link.
I hope this helps.