UIActivityViewController for Facebook not Showing Default Text

I have done one trick to share text and image from UIActivityViewController in iOS. First I need to find if user have clicked on facebook icon from UIActivityView and then open the share dialog of facebook with text and image. This is the only way to share for both text and image. Below is my code. I hope this can save time for the developers. Since Facebook have changed there policies and its really hard to share pre fill text.

Please add UIActivityItemSource in .h file as Delegate

This will be called when user click on share button to show UIActivityViewController.

NSString *textObject = [NSString stringWithFormat:@"%@, %@",shareString,timeDuration];
NSMutableArray *activityItems = [NSMutableArray arrayWithObjects:self, textObject, shareImage, nil];
activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];

And When user click on facebook icon from it.

pragma mark - UIActivityItemSource Protocol

- (id)activityViewController:(UIActivityViewController )activityViewController itemForActivityType:(NSString )activityType {
    
    if ([activityType isEqualToString:UIActivityTypePostToFacebook]) {
    
        [self dismissViewControllerAnimated:activityController completion:nil];
        [self performSelector:@selector(postToFacebook) withObject:self afterDelay:1.0];}
    return nil;
}

-(void)postToFacebook {
    
    [FBSDKSettings setAppID:@""];
    NSArray *imagesListingArray = [[item objectForKey:@"imgs"] valueForKey:@"img"];
    NSString * shareImage = [imagesListingArray objectAtIndex:0];
    
    FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
    content.contentTitle = @"F-Spot";
    content.contentDescription = [NSString stringWithFormat:@"%@  %@", [item valueForKey:@"event_name"],[item valueForKey:@"duration"]];
    content.imageURL = [NSURL URLWithString:shareImage];
    
    FBSDKShareDialog *shareDialog = [[FBSDKShareDialog alloc] init];
    shareDialog.mode = FBSDKShareDialogModeNative;
    if(shareDialog.canShow) {
        shareDialog.mode = FBSDKShareDialogModeFeedBrowser;
    }
    shareDialog.shareContent = content;
    shareDialog.delegate = self;
    [shareDialog show];

}

It would seem Facebook no longer wants developers to pre-fill posts with text. From https://developers.facebook.com/docs/sharing/ios#ios-integration:

Use of the iOS share sheet is subject to Facebook Platform Policy, including section 2.3 which states that apps may not pre-fill. In the context of the share sheet, this means apps may not pre-fill the share sheet's initialText field with content that wasn't entered by people earlier in their use of the app.

Seems they would prefer devs to use the SDK:

While you can use the iOS native view controller API (share sheet) directly, there are several reasons to use the native iOS Share dialog provided by the Facebook SDK. Using the native Share dialog provides a quick way to test that people have signed into Facebook on their iOS 6+ devices. This API also uses the same style block as other parts of the Facebook SDK.


I've found it happens when you have the Facebook app installed. By removing the Facebook app the UIActivityViewController shows the pre-filled text correctly and the image preview is also different. It shows the site url at the bottom of the image.