UIActivityViewController doesn't show FB and Twitter on iOS 7

Au Ris picture Au Ris · Sep 24, 2013 · Viewed 11k times · Source

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

Answer

Petro Korienev picture Petro Korienev · Sep 24, 2013

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.