SetInitialText does not work with iOS 8.3 (facebook, social, SLComposeViewController)

SLComposeViewController functionality no longer works as expected with the latest iPhone iPhone update April 24th. Any source code is ignored, although the setInitialText method returns true as if it were successful. The dialog box always returns Finish, whether you delete Finish or Cancel. I understand that this is an Apple call, and I donโ€™t even use the Facebook SDK, but I confirmed that everything works fine with the previous version of the Facebook application, but when you update the Facebook application on your iPhone, this function no longer works as expected . Note that the result of the completion handler now always returns โ€œDoneโ€ - even when you click โ€œCancelโ€, as well as setInitialText: does nothing. Checked that the same code worked until April 24th.

 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]; } 
+6
source share
2 answers

During this message, the FB still does not allow the initial text to be set, even using the FB SDK.

The way I implemented a workaround for this problem is to copy the contents to the clipboard and show a dialog to notify users that they can paste pre-configured content.

0
source

setInitialText: doesn't work anymore because Facebook has recently changed its addURL: policy, but addURL: still works and can 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; } }]; 

That way I can pre-populate the Facebook post composer URL with my application.

I hope this will be helpful.

-2
source

Source: https://habr.com/ru/post/988303/


All Articles