Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

About "SLComposeViewController" in iOS 11 beta

In my project, I always use SLComposeViewController to share contents with third-party apps, but now, when I update my iPhone to iOS 11 beta, this no longer works.

The SLComposeViewControllerCompletionHandler always callback SLComposeViewControllerResultCancelled.

Why is this?

like image 877
hujie Avatar asked Jul 03 '17 07:07

hujie


2 Answers

I was having problems with regard to the SLComposer in iOS 11. But I just removed the line that checks and apparently the own SDK makes the validacoes to me internally.

Remove this line serves for any SLServiceType:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

So, develop your logic. In my case:

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];

I hope I have helped!

like image 155
Matheus Domingos Avatar answered Nov 03 '22 10:11

Matheus Domingos


iOS 11 removed access to 3rd party accounts (such as Facebook and Twitter) through the Settings App. I’m currently struggling with the same thing.

You now must integrate the functionality with the SDK from the 3rd party. Twitter has a migration page here about steps to take:-

https://dev.twitter.com/twitterkit/ios/migrate-social-framework

I’ve yet to find specific instructions about how to migrate other social networks, but it’s safe to say it will require their 3rd party SDK.

No more easy out-the-box social sharing :-(

like image 13
user8315745 Avatar answered Nov 03 '22 09:11

user8315745