UIActivityViewController adding Message Linkedin and Aridrop - ios

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

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];

Show all options in UIActivityViewController

I have some trouble with create native share dialog.
My goal is share link of my product by native view controller, but I can't do it. I'm trying test code:
NSURL *google = [NSURL URLWithString:#"http://google.com"];
NSArray *activityItems = #[google];
UIActivity *activity = [UIActivity new];
UIActivityViewController *activityViewControntroller = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:#[activity]];
activityViewControntroller.excludedActivityTypes = #[];
[self presentViewController:activityViewControntroller animated:true completion:nil];
And I get no FB and twitter icons. In the other hand, I can see it in safari both icons and when I'm touching it I see "You need configure your account before post".
So, I want the same behavior: icons for all most-popular social networks such as VK, FB, twitter; messengers like whatsapp, viber and telegram. If some of them is not installed I want dialog "You have to log in before" and redirect to safari (e.g. for FB) to log in or open appstore (e.g. for telegram or viber) to install; otherwise I want post message with my link.
I see it like this: exclude all types from activity vc, than forcibly add all icons I need and check each of them on click manually. But in apple docs I've read that "you have to use native behavior for native items instead of create custom". So, will it be correct? Or there are other ways to solve this?
Try this
-(void)clickShare:(UIButton *)sender{
NSArray * activityItems = #[[NSString stringWithFormat:#"Some initial text."], [NSURL URLWithString:#"http://www.google.com"]];
NSArray * applicationActivities = nil;
NSArray * excludeActivities = #[];
UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities];
activityController.excludedActivityTypes = excludeActivities;
[self presentViewController:activityController animated:YES completion:nil];
}
this code working in my project.

Customising UIActivity for UIActivityTypeMessage

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];

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:^{}];

Add Facebook to UIActivityViewController shares

I am trying to let my iOS app to share using the UIActivityViewController, my problem is i can only share with Message and Mail . In other words the apps that are appear in the UIActivityViewController are only the Message and Mail .
How could I add the FaceBook or Twitter to them .
Here is my code
UIButton *shareButton=(UIButton*)sender;
UIActivityViewController *activityVC=[[UIActivityViewController alloc] initWithActivityItems:
#[#"Programmatically Shared post Just for testing ",
[ [videosList objectAtIndex:shareButton.tag ]videoUrl]]
applicationActivities:nil];
I am already logged in with FaceBook App and it is shown when i trying
to share using another app.
You're probably not logged in to Facebook or Twitter in the devices Settings. They won't show up here unless the user is logged in.
Looks like you are not attaching the URL perfectly :
NSString *shareText = #"Text";
NSURL *shareURL = [NSURL URLWithString:#"http://somewebsite.com"];
NSArray *items = [NSArray arrayWithObjects:
shareText,
_shareImage,
shareURL, nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
[activityViewController setValue:shareText forKey:#"subject"];
[self presentViewController:activityViewController animated:YES completion:nil];
NSArray* dataToShare = #[NSURL fileURLWithPath:#"file url"];
// ...or whatever pieces of data you want to share.
UIActivityViewController* activityViewController= [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{}];

Resources