SLServiceTypeFacebook setInitialText is not working

让人想犯罪 __ 提交于 2019-11-27 04:18:28

问题


I am trying to share a text on Facebook with SLServiceTypeFacebook on IOS 8.3. But the popup text box displayed empty. I want it to be displayed with text in it. Below you can see the code I use for that.

 if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) 
 {
       SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

       [controller setInitialText:@"First post from my iPhone app"];
       [self presentViewController:controller animated:YES completion:Nil];
  }

回答1:


It seems to be a problem having installed the latest Facebook app update (v29). Removing it "fixes" the problem.

https://developers.facebook.com/bugs/1632385646995079/ https://developers.facebook.com/bugs/962985360399542/

Update (Jun. 3, 2015)

Well. It seems that the new Facebook policy says that prefilling a message through setInitialText: is a prefill violation.

https://developers.facebook.com/docs/apps/review/prefill

So I guess the only way to share content from now on is the FBSDKShareDialog

https://developers.facebook.com/docs/sharing/ios




回答2:


Gotta love the efficiencies of Facebook. Am a bit late on this but may help someone out.

#import <FBSDKShareKit/FBSDKShareKit.h>

FBSDKShareLinkContent  *content = [[FBSDKShareLinkContent alloc] init];
content.contentURL = self.urlForSocialMedia;
content.contentDescription = self.textForFB;
content.contentTitle = @"Results.";

[FBSDKShareDialog showFromViewController:self
                             withContent:content
                                delegate:self];



回答3:


Before setInitialText add # before this test. Code below. It is working for me

SLComposeViewController *mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    [mySLComposerSheet setInitialText:@"#myInitialTextIsHere"];
    [mySLComposerSheet addURL:[NSURL URLWithString:strURL]];

    [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

        switch (result) {
            case SLComposeViewControllerResultCancelled:
                NSLog(@"Post Canceled");
                break;
            case SLComposeViewControllerResultDone:
                NSLog(@"Post Sucessful");
                break;

            default:
                break;
        }
    }];

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


来源:https://stackoverflow.com/questions/29925810/slservicetypefacebook-setinitialtext-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!