【问题标题】:Confused twitter after sharing messages on iOS 7在 iOS 7 上分享消息后,Twitter 感到困惑
【发布时间】:2014-06-05 04:22:14
【问题描述】:

我将 twitter 与我的 iOS 7 应用程序集成在一起,第一次在 twitter 上分享时运行良好,并在分享“你的推文已发送”后向我显示消息。我在SLComposeViewControllerResultDone 案例中展示。但是,当我在 Twitter 上再次分享相同的消息时会发生什么,它会显示消息“Tweet myappname 是重复的,无法发送。”然后是SLComposeViewControllerResultDone 案例并向我显示我的消息“您的推文已发送”。当用户发送重复消息时,我无法获得任何指示或提示,因为那时我必须阻止自己的警报。请帮助我,我怎么知道用户何时在 Twitter 上发送了重复的消息。谢谢

代码:

if([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0f) { SLComposeViewController *twitterController=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

            // if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
            //{
            SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){

                [twitterController dismissViewControllerAnimated:YES completion:nil];

                switch(result){
                    case SLComposeViewControllerResultCancelled:
                    default:
                    {
                        NSLog(@"Cancelled.....");

                    }
                        break;
                    case SLComposeViewControllerResultDone:
                    {
                        //                        NSLog(@"Posted....");
                        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@""
                                                                            message:@"Your Tweet has been sent."
                                                                           delegate:nil
                                                                  cancelButtonTitle:@"OK"
                                                                  otherButtonTitles:nil];
                        [alertView show];


                    }
                        break;
                }};


            [twitterController setInitialText:@"MY App"];
            [twitterController addURL:[NSURL URLWithString:@"http://google.com/"]];

            [twitterController setCompletionHandler:completionHandler];
            [self presentViewController:twitterController animated:YES completion:nil];

        }

【问题讨论】:

  • 您不能在短时间内发送两条完全相同的推文。它是 twitter 的事情..不是 iOS 7 的问题..
  • 谢谢,我明白这一点,但是作为开发人员,当用户在短时间内发送重复消息时,我必须在 Result Done 案例中阻止我自己的消息,这可能是 twitter 给我们任何关于重复消息的提示吗?
  • 如果您想限制用户在短时间内发送相同的推文或在特定时间成功分享后禁用“分享”按钮,则需要在代码中添加“NSTimer”。但我仍然会说你不需要这样做,因为 twitter 本身给你的信息是“重复”..
  • 谢谢@JohnDoe,我不想限制用户发送相同或重复的消息,我只想隐藏我的警报,上面写着“您的推文已发送”。当用户发送重复消息时。可能吗?
  • 为什么不添加一个简单的 if - 条件.. if([message isEqualToString:@"Tweet myappname 是重复的,无法发送。"]){ NSLog(@"随便你想在这里"); } else { //显示警报 }

标签: ios twitter ios7


【解决方案1】:

您不应依赖SLComposeViewControllerResultDone 来假设推文是成功的。此外,您应该将其留给操作系统,以向用户显示带有适当消息的警报。

您不应该尝试深入了解响应以获取消息。操作系统将在出现错误时显示适当的警报,否则它将尝试播放您为成功推文配置的声音。

【讨论】:

    猜你喜欢
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 2012-09-18
    • 2012-03-01
    • 1970-01-01
    • 2017-07-27
    • 2012-03-04
    • 2020-05-23
    相关资源
    最近更新 更多