ActivityItems in UIActivityViewController don't show up - ios

I'm developing an app in iOS 7 and in it I need to show an activity controller. Below is my code,
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:#[UIActivityTypeSaveToCameraRoll, UIActivityTypePostToFacebook, UIActivityTypePostToTwitter, UIActivityTypeMail, UIActivityTypeMessage, UIActivityTypePrint] applicationActivities:nil];
[self presentViewController:activityVC animated:YES completion:nil];
But when its presented, this is how it looks.
None of the activity types I added in the array shows up. Why is this happening? Am I missing something? I'd like some help to get this working. I especially need the Facebook, twitter sharing and the saving to the local storage options here.
Thank you.
Edit: I checked on a real device and the Facebook and Twitter sharing options show up. However UIActivityTypeSaveToCameraRoll, UIActivityTypePrint still aren't showing up.

The Items will show up only if you have integrated them to your Device.
If you have integrated facebook and Logged into facebook in the settings then Facebook will appear along the Items. That means your device must be Synchronised with the native Facebook, Twitter, etc Apps for them to show up in the UIActivityViewController
Edit:
Try using like this
UIActivityViewController *ActivityView;
ActivityView =
[[UIActivityViewController alloc]
initWithActivityItems:Items applicationActivities:nil];
[self presentViewController:ActivityView animated:YES completion:nil];

Related

Change activity items base on which application is selected for sharing in iOS

I share an image with text to othe applications.
NSArray *activityItems = #[title, finalImage];
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypePostToTwitter, UIActivityTypePostToWeibo];
[self presentViewController:activityVC animated:TRUE completion:nil];
Problem with this code is that I share title and image for all destination apps. but for instance, WhatsApp has problem when I share image with title. When I delete title it will correctly share the image but when I add title to activityItems, it just sends title. I want to detect if whats app is selected and then just send the image

How to customise UIActivityViewController to my selected apps?

I have customised UIActivityViewController as possible from my side. I have excluded all items from it as listed below:-
UIActivityViewController *controller = [[UIActivityViewController alloc] initWithActivityItems:#[videoURL] applicationActivities:nil];
controller.excludedActivityTypes = #[UIActivityTypePostToWeibo,
UIActivityTypeMail,
UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAddToReadingList,
UIActivityTypePostToFlickr,
UIActivityTypePostToVimeo,
UIActivityTypePostToTencentWeibo,
UIActivityTypeAirDrop,
UIActivityTypeOpenInIBooks,
#"com.apple.mobilenotes.SharingExtension",
#"com.apple.reminders.RemindersEditorExtension"];
[self presentViewController:controller animated:YES completion:nil];
Now I only want to show Message, Facebook, Instagram, and WhatsApp in the ActivityController.
1- How can I exclude all other installed app from list to show only above mentioned apps?
2- I also wants to exclude 'Add to iCloud Drive' from list.
Note: I have already tried customised action sheet and able to share image only with it. But I want to share video in above mentioned apps. And they are not providing any way to share video.
Please help, thanks in advance.
Attachments after my code execution.

UIActivityViewController show in different language

i want to remove or translate 'more' from english to russian.
Controller initiated simply as follows:
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:#[fbAct, vk2Act, okAct, twAct, gpAct, mailAct]];
[self presentViewController:activityVC animated:YES completion:nil];
You can't hide or remove more button according to apple policy
It comes as the default language of iPhone
If u need to change that you can use custom library https://github.com/overshare/overshare-kit

iOS native way to share files to any possible apps

I'm currently implementing an iOS app using objective-C, which has a function that users may share a file with other friend or other app (like upload the file to Dropbox, Google Drive, attach the file to Mail, share the file to Facebook Messenger, Whatsapp, via Bluetooth, etc).
Is there a native way to implement this share function that can detect all apps which allows sharing a file, while I don't need to do it one by one?
You want to use UIActivityViewController. Below is an example from NSHipster, which is probably the most comprehensive article I've seen on the subject. And Apple has some good documentation here.
NSString *string = ...;
NSURL *URL = ...;
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:#[string, URL]
applicationActivities:nil];
[navigationController presentViewController:activityViewController
animated:YES
completion:^{
// ...
}];
This provide full answer for iPhone and iPad devices
ViewController *contentViewController = [[ViewController alloc] init];
// Present the view controller using the popover style.
contentViewController.modalPresentationStyle = UIModalPresentationPopover;
[self presentViewController:contentViewController
animated:YES
completion:nil];
// Get the popover presentation controller and configure it.
UIPopoverPresentationController *presentationController =[contentViewController popoverPresentationController];
presentationController.permittedArrowDirections = UIPopoverArrowDirectionUp;
presentationController.sourceView = self.view;
presentationController.sourceRect = self.view.frame;
UIPopoverPresentationController should have a non-nil sourceView or barButtonItem set before the presentation occurs on iOS 9

iOS 8.3 Facebook error Not logged In

I'am sharing a NSString and NSURL, using the native UIActivityViewController
The user is logged in into Facebook both in Settings and also in the Facebook App
but after iOS 8.3 i'am getting this error... moreover, on older devices, the dialog confirmation is obscured by the keyboard, making it impossible to confirm or decline
UIActivityViewController *vc = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:applicationActivities];
NSArray *excludeActivities = #[UIActivityTypeAssignToContact];
vc.excludedActivityTypes = excludeActivities;
if (IsUserInterfaceIdiomPad) {
vc.popoverPresentationController.sourceView = self.navigationController.view;
}
[self.navigationController presentViewController:vc animated:YES completion:^{
}];
Yes, this is a bug that went out in Version 29 of the Facebook application. We (Facebook) are working on a fix and hope that it will ship soon.

Resources