18

I am trying to share some items using UIActivityViewController. On iOS 6 it works fine. But when I test it on iOS 7 only mail icon shows up. In doubt that my SDK was too old I downloaded the most recent one, but it's still behaves the same. I tested on both simulator and a device with facebook installed on it, no luck.

Now I am running out of ideas what I do wrong.

Here is my code

- (void)shareButtonWasTapped:(BMPopUpMenuView *)popUpMenu {

NSString *shareText;

if (_correctPatternFound) {
    shareText = @"Yey, I solved a puzzle!";
}
else {
    shareText = @"I am solving a photzle...";
}

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

activityViewController.excludedActivityTypes =   @[UIActivityTypeCopyToPasteboard,
                                                   UIActivityTypePostToWeibo,
                                                   UIActivityTypeSaveToCameraRoll,
                                                   UIActivityTypeCopyToPasteboard,
                                                   UIActivityTypeMessage,
                                                   UIActivityTypeAssignToContact,
                                                   UIActivityTypePrint];

[self presentViewController:activityViewController animated:YES completion:nil];
}
Petro Korienev
  • 4,007
  • 6
  • 34
  • 43
Au Ris
  • 4,541
  • 2
  • 26
  • 53

2 Answers2

30

They won't show when you don't have Twitter and Facebook accounts set up in settings. Facebook or twitter app are not enough - you should have explicitly set accounts.
Maybe it's not really cool, (user may want to share something on fb or twitter and perform login for it) but Apple considered these activities should work so in iOS 7.

Petro Korienev
  • 4,007
  • 6
  • 34
  • 43
  • 4
    (Or they didn't have time to fix the bug ;) ) – Marty Sep 26 '13 at 17:06
  • Even i faced the same issue and adding twitter and facebook credentials in settings did the wonder. In iOS7 Apple have done stupid changes. – Ankit Jain Sep 30 '13 at 09:29
  • 1
    It's not just for iOS 7. The same behavior in iOS 6 as well. I hoped this behavior would be changed in iOS 7 but it didn't... Maybe they didn't want to promote those social media but they should have provided a choice to developers. – atisman Dec 04 '13 at 03:11
  • on iOS 8.3 facebook seems to be missing, even thou on a user device it been set up... @Petro what do you mean by explicitly set accounts? – Shams Ahmed Apr 27 '15 at 23:54
7

As Ahmed said above There is a problem in IOS 8.3 to use Facebook text sharing even if you add Facebook account in the setting.

I recently post this problem in sharing facebook text using uiactivityviewcontroller

In my opinion this is a bug that apple have to fix. maybe in the next version...

Community
  • 1
  • 1
user3728728
  • 885
  • 2
  • 11
  • 14