OGeek|极客世界-中国程序员成长平台

标题: ios - 在设置中将 iOS 应用程序添加到 Twitter 帐户? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:22
标题: ios - 在设置中将 iOS 应用程序添加到 Twitter 帐户?

我在我的应用程序中添加了一些共享功能,以允许用户发布到 Facebook 和 Twitter。我决定使用社交共享框架,因为它完全符合我的需要并且运行良好。

但是我注意到我的应用程序没有向用户请求权限,它假定它具有权限并检查是否有帐户设置。

我在这里看到的问题是由于这个 - 我的应用程序没有出现在设置 -> Twitter 下的“允许这些应用程序使用你的帐户”部分下。

她是我想要共享项目时使用的代码 - 用户点击 UIButton 会显示带有各种选项的 UIActionSheet”

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]){

            SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

            SLComposeViewControllerCompletionHandler completionBlock = ^(SLComposeViewControllerResult result){

                if (result == SLComposeViewControllerResultCancelled){
                    NSLog (@"Cancelled");
                }else {
                    NSLog(@"Done");
                }

                [controller dismissViewControllerAnimated:YES completion:nil];
            };

            controller.completionHandler = completionBlock;

            NSURL *url = [NSURL URLWithString:self.item.url];

            /* Adding the text to the Tweet */
            [controller setInitialText"Online now!"];
            [controller addURL:url];
            [controller addImage:self.imageView.image];

            [self presentViewController:controller animated:YES completion:nil];
    }
    else {
            [self showUserAlert"" message"lease make sure your FaceBook account has been setup on this device"
                       delegate:self
              cancelButtonTitle"Okay"];
    }

如何先申请访问权限?并将应用程序添加到 iOS 的设置部分,以便用户可以打开或关闭它?



Best Answer-推荐答案


我认为您不需要权限,因为您的应用无法在没有用户操作的情况下发布。用户拥有所有控制权。

您可以使用 TWTweetComposeViewController 中的 canSendTweet 方法检查是否可以共享。查找 Xcode 文档。我确信 Apple 对 Facebook 也有类似的东西。

Apple documentation

关于ios - 在设置中将 iOS 应用程序添加到 Twitter 帐户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24160517/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4