UIActivityViewController Facebook share text

4.1k views Asked by At

I'm trying to post to Facebook/Twitter with prefilled text by using UIActivityViewController. But I am not able to populate the pre-filled text, below is my sample code.

UIImage* shareImage =  [self saveVersionGraphicsAndThumbnailImage:self.drawingView];
NSString* message = @"My post - ";
NSArray* shareItems = @[message, shareImage];

UIActivityViewController * avc = [[UIActivityViewController alloc] initWithActivityItems:shareItems applicationActivities:nil];

if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
    UIPopoverPresentationController *presentationController = [avc popoverPresentationController];
    presentationController.sourceView = sender;
}
[self presentViewController:avc animated:YES completion:nil];

Please help to to solve this issue, Thanks in advance.

2

There are 2 answers

2
Ramesh R C On

Yes i am able to do now. i changed the shareitem array to

NSArray * activityItems = @[[NSString stringWithFormat:@"My Post - "], shareImage];

Thanks a lot.

0
agy On

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.