Search code examples
iosfacebooksharesharing

Facebook sharing on iOS works on some devices, but not others


So I am doing just a basic facebook share inside my app, and it works fine on my devices (iPhone 6 OS 9.1 and iPad air 9.02) but doesn't work on my coworkers iPad Air 2 8.4.1 or iPhone 6 Plus 9.1. Anyone have any clue as to why this would be?

They are signed into facebook in the device settings. They also have the facebook app installed (I don't have the app, just signed in through settings)

Here's the screenshot of my device showing the message to share, the other devices just show the image and no text.

enter image description here

Here's the code I am using to share

- (void)shareTapped {
    UIImage *image = self.pictureView.image;

    NSString *postText = [NSString stringWithFormat:@"%@\n*%@\n%@\n%@, %@ %@", self.event.shortDescription, self.event.eventCode, self.event.address, self.event.city, self.event.state, self.event.zip];
    [[UtilitiesObject sharedInstance] shareMessage:postText image:image parentVC:self];
}

- (void)shareMessage:(NSString *)msg image:(UIImage *)image parentVC:(UIViewController *)parentVC {
    NSArray *activityItems = @[msg];
    if (image) {
        activityItems = @[msg, image];
    }

    UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

    // Tailor the list of services displayed
    activityController.excludedActivityTypes = @[UIActivityTypeAssignToContact,
                                             //UIActivityTypePostToFacebook,
                                             //UIActivityTypePostToTwitter,
                                             //UIActivityTypeMail,
                                             UIActivityTypeMessage,
                                             UIActivityTypeSaveToCameraRoll,
                                             UIActivityTypePrint,
                                             UIActivityTypePostToWeibo,
                                             UIActivityTypeCopyToPasteboard];

    activityController.popoverPresentationController.sourceView = parentVC.view;

        [activityController setCompletionWithItemsHandler:
 ^(NSString *activityType, BOOL completed, NSArray *returnedItems, NSError *activityError) {
         if ([activityType isEqualToString: UIActivityTypeMail]) {
             NSLog(@"Mail");
         }
         if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
             NSLog(@"Facebook");
         }
         if ([activityType isEqualToString:UIActivityTypePostToTwitter]) {
             NSLog(@"Twitter");
         }
     }];

    [parentVC presentViewController:activityController animated:YES completion:nil];
}

Solution

  • Facebook's platform policy does not allow apps to prefill the message field. In this case, because you don't have the Facebook app, it's using Apple's share sheet, which allows prefill but is against FB's platform policy. In your friends case, they're likely seeing the Facebook app's share extension, which correctly enforces the policy, and does not allow prefill.