setInitialText method in SLComposeViewController iOS 8.3 does not show text in Facebook sheet
Asked Answered
P

2

20

The code snippet below is the callback for an on screen button. The Facebook sheet appears but contains no text. However, if you replace SLServiceTypeFacebook with SLServiceTypeTwitter it does show the initial text. I am using XCode 6.3.1 and iOS 8.3 on an iPhone 6. Thank you in advance.

-(IBAction)facebookButton:(id)sender
{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])
    {
        NSString* facebookText = @"Awesome App";
        SLComposeViewController *fbPostSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
        [fbPostSheet setInitialText:facebookText];
        [self presentViewController:fbPostSheet animated:YES completion:nil];
    }
    else{
         UIAlertView *alertView = [[UIAlertView alloc]
                              initWithTitle:@"Unable to Connect to Facebook"
                              message:@"Make sure your device has an internet connection and you have your Facebook account setup in the Settings App"
                              delegate:self
                              cancelButtonTitle:@"OK"
                              otherButtonTitles:nil];
        [alertView show];
    }
}        
Pharr answered 29/4, 2015 at 12:4 Comment(3)
The initial text being removed from the Facebook dialog has become an issue since Facebook's latest update. You are not alone.Dolf
Facing same problem in ios8.2 also and found no solution yet.Beverlybevers
Same problem here i have 8.0Djakarta
H
15

If you delete the Facebook app on the device, the initial text will appear.

Harkins answered 1/5, 2015 at 5:3 Comment(9)
Deleting the Facebook app on my iPhone does allow the inititial text to appear. However, I cannot ask my users to delete their facebook app so they can post their score on Facebook.Pharr
You may want to have a custom UI for your case. Please remind that you have to submit your app for Facebook review. I had also googled this issue but sadly i did not find any documentations about this..Harkins
I'm having the same issue in my game. But, to be clear, @Chrisswong, are you saying that we have to register our apps with Facebook to fix this issue?Mcclurg
Making your own UI for Facebook sharing allows you provide any initial texts for Facebook sharing. However, you must register on Facebook developer site , enable "publish_actions" permission and submit iOS simulator build for Facebook review so that you can go live with Facebook sharing and share to public. You must be aware of this POLICY for the initial text you provided.Harkins
@Harkins as I understand from Policy link you provided, Facebook now reject using of "prefill". So making your own compose controller will not solve the problem. I guess that this is a reason of change in iOS 8.3.Durra
@JohnTracid In fact one of my app is using custom UI for Facebook sharing. However, i pre-filled the text inside a textview so that user can edit the text and finally Facebook review approved this. From i understand the "pre-fill" is something that the user is not able to edit and it shows in the shared content.Harkins
Use Facebook share dialogFurman
@Harkins can you share the link of your application so that we get an idea of creating custom dialog. I am sucked with the same since few weeks. ThanksTenorio
@ManiKhalil no worries! it was pretty long ago so most of us aware this issues and provide other alternatives to the users.Harkins
P
1

It actually works if you set the text inside the completion handler:

NSString* facebookText = @"Awesome App";
SLComposeViewController *fbPostSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
//[fbPostSheet setInitialText:facebookText];
[self presentViewController:fbPostSheet animated:YES completion:^
{
    [fbPostSheet setInitialText:facebookText];
}];
Peru answered 4/2, 2016 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.