简体   繁体   English

关于iOS 11 beta中的“SLComposeViewController”

[英]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. 在我的项目中,我总是使用SLComposeViewController与第三方应用程序共享内容,但是现在,当我将我的iPhone更新到iOS 11测试版时,这不再有效。

The SLComposeViewControllerCompletionHandler always callback SLComposeViewControllerResultCancelled . SLComposeViewControllerCompletionHandler始终回调SLComposeViewControllerResultCancelled

Why is this? 为什么是这样?

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. 我在iOS 11中遇到了关于SLComposer的问题。但我刚刚删除了检查的行,显然自己的SDK在内部为我提供了有效的问题。

Remove this line serves for any SLServiceType : 删除此行适用于任何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! 我希望我有所帮助!

iOS 11 removed access to 3rd party accounts (such as Facebook and Twitter) through the Settings App. iOS 11通过“设置应用”删除了对第三方帐户(如Facebook和Twitter)的访问权限。 I'm currently struggling with the same thing. 我目前正在努力做同样的事情。

You now must integrate the functionality with the SDK from the 3rd party. 您现在必须将功能与来自第三方的SDK集成。 Twitter has a migration page here about steps to take:- Twitter在此处有一个迁移页面,介绍了要采取的步骤: -

https://dev.twitter.com/twitterkit/ios/migrate-social-framework 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. 我还没有找到有关如何迁移其他社交网络的具体说明,但可以肯定地说它需要他们的第三方SDK。

No more easy out-the-box social sharing :-( 没有更容易开箱即用的社交分享:-(

For iOS 11 this line: 对于iOS 11这一行:

 ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) 

is always returning NO 总是回归NO

I replaced it with check if user has Facebook app installed with: 如果用户安装了Facebook应用程序,我将其替换为:

static NSString *const canOpenFacebookURL = @"fbauth2";

+ adding it to LSApplicationQueriesSchemes in plist +将其添加到plist中的LSApplicationQueriesSchemes

-(BOOL)isFacebookAppInstalled {
    NSURLComponents *components = [[NSURLComponents alloc] init];
    components.scheme = canOpenFacebookURL;
    components.path = @"/";
    return [[UIApplication sharedApplication]
            canOpenURL:components.URL];
}

And then just call SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; 然后只需调用SLComposeViewController *composeVC = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

as usual, the same how Matheus Domingos described. 像往常一样,马修斯多明戈斯如何描述。 But with this check at least you know that user has facebook app installed. 但至少你知道用户已经安装了facebook app。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM