setInitialText not work with IOS 8.3 (facebook,social,SLComposeViewController)
Asked Answered
B

2

6

The functionality of SLComposeViewController no longer works as expected with the newest Facebook iPhone app update as of April 24th. Any initial text specified is ignored, though the setInitialText method returns true as if it was successful. The dialog then always returns "Done" whether you hit "Done" or "Cancel". I realize this is an Apple call and I'm not even using the Facebook SDK, but I have verified that everything works perfectly with the previous version of the Facebook App installed but when you upgrade the Facebook app on your iPhone, this functionality no longer works as expected. Note that the result of the completion handler now always returns "Done" - even when you hit "Cancel" and also, the setInitialText: does nothing now. Verified that the same code worked pre-the april 24th release.

if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

    controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];



    [controller setInitialText:@"hiiiiiii"];
    [controller setCompletionHandler:^(SLComposeViewControllerResult result)
     {
         if (result == SLComposeViewControllerResultCancelled)
         {
             NSLog(@"The user cancelled.");
         }
         else if (result == SLComposeViewControllerResultDone)
         {
             NSLog(@"The user posted to Facebook");
         }
     }];
    [self presentViewController:controller animated:YES completion:nil];
}
else
{
    SCLAlertView *alert = [[SCLAlertView alloc] init];
    [alert showWarning:self title:@"alert" subTitle:@"facebook not installed"  closeButtonTitle:@"ok" duration:0.0f];
}
Backplate answered 1/6, 2015 at 9:54 Comment(5)
prefilling is not allowed on facebook, if that is what you are trying to doGelasius
the prefilling is allowed on facebook and this code (setInitialText:) was work on ios7 , in my app i need it to fill automatically the description of the selected item.Backplate
prefilling is NOT allowed on facebook, that is a fact.Gelasius
Copying from developers.facebook.com/policy 2.3: "Don't prefill captions, comments, messages, or the user message parameter of posts with content a person didn’t create, even if the person can edit or remove the content before sharing". That is pretty clear to meJerrold
@WizKid: The statement is very clear to me as well dear but as it is said in the statement itself that "even if the person can edit or remove the content before sharing", SLCompose...Controller allows this, so, I think there should not be any issue as Apple controller asks to edit the text before posting. Or how can a user share the app which he is using? I don't think user is willing to type the whole link himself. I need to put a "share my app" but in my app. Is there any way to handle this?Joniejonina
B
0

At the time of this post, FB's still not allowing to set initial text, even using FB SDK.

A way I implemented to bypass the issue is to copy the content to clipboard and show a dialog to notify users that they can paste the preset content.

Barnwell answered 9/2, 2016 at 5:57 Comment(0)
B
-2

setInitialText: is not working anymore because Facebook has recently changed its policy about prefilling, but addURL: is still working and may be useful.

 SLComposeViewController *mySLComposerSheet = [[SLComposeViewController alloc] init];
mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];
NSURL *url = [[NSURL alloc] initWithString:linkString];
[mySLComposerSheet addURL:url];

[self presentViewController:mySLComposerSheet animated:YES completion:nil];

[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
    NSString *output;
    switch (result) {
        case SLComposeViewControllerResultCancelled:
            NSLog(@"SLComposeViewControllerResultCancelled");
            break;
        case SLComposeViewControllerResultDone:
            NSLog(@"SLComposeViewControllerResultDone");
            break;
    }
}];

This way I can prefill Facebook post composer with the URL to my App.

I hope it to be useful.

Brewer answered 17/7, 2015 at 14:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.