Customising UIActivity for UIActivityTypeMessage - ios

I'm sharing an image and its description text using UIActivityType. I need to share the URL of the image if I choose SMS sharing option. How can I do that? Currently I'm sharing the image and data to Facebook and Twitter. How to send the URL in case that SMS option is selected?

You can share the image using SMS option in the same way that you are doing it with Facebook and Twitter.
The activityType for SMS is UIActivityTypeMessage. It is the built-in activityType.
So the only thing you need to do is provide image and image description as activityItems while creating your UIActivityController.
The code snippet is given below:
NSString *imageDescription = #"Image Description Goes Here";
UIImage *image = [UIImage imageNamed:#"Image_Name"];
NSArray *items = [NSArray arrayWithObjects: imageDescription,image,nil];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];

Related

Share options application link in IOS

I have a share button in my app on which when user click it shows a popup message to share the link of my application to different social sites, but when u click it shows only Facebook icon to share the link.How can I get different other sites access like Gmail, Twitter, Instagram, Yahoo and WhatsApp. This is my code
NSString *texttoshare = #"myURL"; //this is your text string to share
NSArray *activityItems = #[texttoshare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint];
[self presentViewController:activityVC animated:TRUE completion:nil];

Airdrop option missing in UIActivityViewController

For some reason when I use ActivityViewController from my app I don't get the option to share using Airdrop. If i use it from Chrome, I do get the option:
This is the code that I'm using:
NSMutableArray * items = [NSMutableArray new];
[items addObject:#"text for share"];
[items addObject:[UIImage imageNamed:#"image"]];
NSArray *activityItems = [NSArray arrayWithArray:items];
UIActivityViewController *activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:activityItems
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{
.....
}];
But I only get this:
How do I add the Airdrop option?
In order to be able to send something over AirDrop the item will need to be a URL. I couldn't find the official documentation, but in this Apple AirDrop Example it states:
URLs can be used as a simple way to transfer information between devices. Apps can easily parse a received URL to determine what action to take. After an app registers a URL scheme (including custom schemes), the system will know to launch that app when a URL of that type is received.

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 adding Message Linkedin and Aridrop

I have used the following code to implement UIActivityViewController.
UIActivityViewController *ActivityView;
NSArray *Items;
Items = [NSArray arrayWithObjects:
#"A text line",
nil];
ActivityView =
[[UIActivityViewController alloc]
initWithActivityItems:Items applicationActivities:nil];
[ActivityView setExcludedActivityTypes:[NSArray arrayWithObjects:
UIActivityTypeCopyToPasteboard,nil]];
[self presentViewController:ActivityView animated:YES completion:nil];
In the above code when i add Facebook and Twitter accounts in the phone settings, they are shown in the UIActivityViewController. But i am not able to show Airdrop, Linkedin and Message options in th UIActivityViewController.
Is there some other specific method to implement Airdrop, Linkedin and Message along with the Facebook and Twitter in the UIActivityViewController

iOS6 UIActivity tweetsheet text not populating

I'm using UIActivity class for the first time, with very little modification:
NSString *textToShare = #"my text";
UIImage *imageToShare = [UIImage imageNamed:#"myImage.png"];
NSArray *itemsToShare = #[textToShare, imageToShare];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];
[self presentViewController:activityVC animated:YES completion:nil];
When I test this, emails, messages, and Facebook are automatically populated with both the textToShare and the imageToShare, while only the image appears on the tweet sheet.
Apple UIActivity class documentation says UIActivityTypePostToTwitter will accept NSString, NSAttributedString, UIImage, AVAsset, and NSURL objects.
The WWDC video examples largely feature Facebook examples, and I've never dealt with Twitter before.
I thought it would populate just like the email/message/Facebook did, and I'm not sure where to go from here. Seems like it should be really simple, but my searches result in much more complex custom-Twitter problems and solutions.
"my text" was a few characters over the 140 character limit of a tweet. Shortened the text, tweet sheet populates.

Resources